From c446d20bd543065a6de73c78c49bf1a04b29a8f9 Mon Sep 17 00:00:00 2001 From: xiaoweim Date: Thu, 17 Oct 2024 00:52:22 +0000 Subject: [PATCH 1/4] feat: add mockgcp for bigqueryroutine --- config/tests/samples/create/harness.go | 1 + mockgcp/mockbigquery/routine.go | 169 ++++++++ mockgcp/mockbigquery/service.go | 3 +- ...ed_object_basicbigqueryroutine.golden.yaml | 33 ++ .../basicbigqueryroutine/_http.log | 349 +++++++++++++++ .../create.yaml | 3 +- .../dependencies.yaml | 8 +- .../basicbigqueryroutine/update.yaml | 27 ++ ..._object_bigqueryroutineautogen.golden.yaml | 34 ++ ...ed_object_fullybigqueryroutine.golden.yaml | 40 ++ .../fullybigqueryroutine/_http.log | 400 ++++++++++++++++++ .../fullybigqueryroutine/create.yaml | 34 ++ .../fullybigqueryroutine/dependencies.yaml | 20 + .../fullybigqueryroutine/update.yaml | 34 ++ 14 files changed, 1147 insertions(+), 8 deletions(-) create mode 100644 mockgcp/mockbigquery/routine.go create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log rename pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/{bigqueryroutineautogen => basicbigqueryroutine}/create.yaml (94%) rename pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/{bigqueryroutineautogen => basicbigqueryroutine}/dependencies.yaml (81%) create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_bigqueryroutineautogen.golden.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/create.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/dependencies.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index 581b4ca36c..f825320197 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -728,6 +728,7 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured case schema.GroupKind{Group: "bigquery.cnrm.cloud.google.com", Kind: "BigQueryDataset"}: case schema.GroupKind{Group: "bigquery.cnrm.cloud.google.com", Kind: "BigQueryTable"}: + case schema.GroupKind{Group: "bigquery.cnrm.cloud.google.com", Kind: "BigQueryRoutine"}: case schema.GroupKind{Group: "bigqueryanalyticshub.cnrm.cloud.google.com", Kind: "BigQueryAnalyticsHubDataExchange"}: diff --git a/mockgcp/mockbigquery/routine.go b/mockgcp/mockbigquery/routine.go new file mode 100644 index 0000000000..b0c107e031 --- /dev/null +++ b/mockgcp/mockbigquery/routine.go @@ -0,0 +1,169 @@ +// Copyright 2024 Google LLC +// +// 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 mockbigquery + +import ( + "context" + "net/http" + "time" + + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/httpmux" + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" + pb "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/generated/mockgcp/cloud/bigquery/v2" + "github.com/golang/protobuf/ptypes/empty" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +var defaultLanguage = "SQL" +var DeterminismLevelUnspecified = "DETERMINISM_LEVEL_UNSPECIFIED" + +type routinesServer struct { + *MockService + pb.UnimplementedRoutinesServerServer +} + +func (s *routinesServer) GetRoutine(ctx context.Context, req *pb.GetRoutineRequest) (*pb.Routine, error) { + name, err := s.buildRoutineName(req.GetProjectId(), req.GetDatasetId(), req.GetRoutineId()) + if err != nil { + return nil, err + } + + fqn := name.String() + + obj := &pb.Routine{} + if err := s.storage.Get(ctx, fqn, obj); err != nil { + if status.Code(err) == codes.NotFound { + return nil, status.Errorf(codes.NotFound, "Not found: Routine %s:%s.%s", name.Project.ID, name.DatasetID, name.RoutineID) + } + return nil, err + } + if obj.Language == nil { + obj.Language = &defaultLanguage + } + if obj.DeterminismLevel != nil && *obj.DeterminismLevel == DeterminismLevelUnspecified { + obj.DeterminismLevel = nil + } + + return obj, nil +} + +func (s *routinesServer) InsertRoutine(ctx context.Context, req *pb.InsertRoutineRequest) (*pb.Routine, error) { + name, err := s.buildRoutineName(req.GetProjectId(), req.GetDatasetId(), req.GetRoutine().GetRoutineReference().GetRoutineId()) + if err != nil { + return nil, err + } + + fqn := name.String() + + now := time.Now() + + obj := proto.Clone(req.GetRoutine()).(*pb.Routine) + + if obj.RoutineReference == nil { + obj.RoutineReference = &pb.RoutineReference{} + } + if obj.GetRoutineReference().ProjectId == nil { + obj.RoutineReference.ProjectId = req.ProjectId + } + obj.CreationTime = PtrTo(now.UnixMilli()) + obj.LastModifiedTime = PtrTo(now.UnixMilli()) + obj.Etag = PtrTo(computeEtag(obj)) + + if err := s.storage.Create(ctx, fqn, obj); err != nil { + return nil, status.Errorf(codes.Internal, "error creating routine: %v", err) + } + if obj.Language == nil { + obj.Language = &defaultLanguage + } + if obj.DeterminismLevel != nil && *obj.DeterminismLevel == DeterminismLevelUnspecified { + obj.DeterminismLevel = nil + } + return obj, nil +} + +func (s *routinesServer) UpdateRoutine(ctx context.Context, req *pb.UpdateRoutineRequest) (*pb.Routine, error) { + name, err := s.buildRoutineName(req.GetProjectId(), req.GetDatasetId(), req.GetRoutineId()) + if err != nil { + return nil, err + } + + fqn := name.String() + + existing := &pb.Routine{} + if err := s.storage.Get(ctx, fqn, existing); err != nil { + return nil, err + } + + now := time.Now() + + updated := req.GetRoutine() + updated.RoutineReference = existing.RoutineReference + + updated.CreationTime = existing.CreationTime + updated.LastModifiedTime = PtrTo(now.UnixMilli()) + updated.RoutineType = existing.RoutineType + updated.Etag = PtrTo(computeEtag(updated)) + + if err := s.storage.Update(ctx, fqn, updated); err != nil { + return nil, err + } + + return updated, err +} + +func (s *routinesServer) DeleteRoutine(ctx context.Context, req *pb.DeleteRoutineRequest) (*empty.Empty, error) { + name, err := s.buildRoutineName(req.GetProjectId(), req.GetDatasetId(), req.GetRoutineId()) + if err != nil { + return nil, err + } + + fqn := name.String() + + deleted := &pb.Dataset{} + if err := s.storage.Delete(ctx, fqn, deleted); err != nil { + return nil, err + } + + httpmux.SetStatusCode(ctx, http.StatusNoContent) + + return &empty.Empty{}, nil +} + +type routineName struct { + Project *projects.ProjectData + DatasetID string + RoutineID string +} + +func (n *routineName) String() string { + return "projects/" + n.Project.ID + "/datasets/" + n.DatasetID + "/routines/" + n.RoutineID +} + +func (s *MockService) buildRoutineName(projectName string, datasetID string, routineID string) (*routineName, error) { + project, err := s.Projects.GetProjectByID(projectName) + if err != nil { + return nil, err + } + + name := &routineName{ + Project: project, + DatasetID: datasetID, + RoutineID: routineID, + } + + return name, nil +} diff --git a/mockgcp/mockbigquery/service.go b/mockgcp/mockbigquery/service.go index 84983bf86d..af075337f8 100644 --- a/mockgcp/mockbigquery/service.go +++ b/mockgcp/mockbigquery/service.go @@ -53,10 +53,11 @@ func (s *MockService) ExpectedHosts() []string { func (s *MockService) Register(grpcServer *grpc.Server) { pb.RegisterDatasetsServerServer(grpcServer, &datasetsServer{MockService: s}) pb.RegisterTablesServerServer(grpcServer, &tablesServer{MockService: s}) + pb.RegisterRoutinesServerServer(grpcServer, &routinesServer{MockService: s}) } func (s *MockService) NewHTTPMux(ctx context.Context, conn *grpc.ClientConn) (http.Handler, error) { - mux, err := httpmux.NewServeMux(ctx, conn, httpmux.Options{}, pb.RegisterDatasetsServerHandler, pb.RegisterTablesServerHandler) + mux, err := httpmux.NewServeMux(ctx, conn, httpmux.Options{}, pb.RegisterDatasetsServerHandler, pb.RegisterTablesServerHandler, pb.RegisterRoutinesServerHandler) if err != nil { return nil, err } diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml new file mode 100644 index 0000000000..5372b85c84 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml @@ -0,0 +1,33 @@ +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + annotations: + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/state-into-spec: absent + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 1 + labels: + cnrm-test: "true" + name: bigqueryroutine-${uniqueId} + namespace: ${uniqueId} +spec: + datasetRef: + name: bigquerydataset${uniqueId} + definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + + y); + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + routineType: PROCEDURE +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + creationTime: "1970-01-01T00:00:00Z" + lastModifiedTime: "1970-01-01T00:00:00Z" + observedGeneration: 1 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log new file mode 100644 index 0000000000..5024b2b3ec --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log @@ -0,0 +1,349 @@ +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "Not found: Dataset ${projectId}:bigquerydataset${uniqueId}", + "reason": "notFound" + } + ], + "message": "Not found: Dataset ${projectId}:bigquerydataset${uniqueId}", + "status": "NOT_FOUND" + } +} + +--- + +POST https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}" + }, + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "location": "us-central1" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "Not found: Routine ${projectId}:bigquerydataset${uniqueId}.bigqueryroutine${uniqueId}", + "reason": "notFound" + } + ], + "message": "Not found: Routine ${projectId}:bigquerydataset${uniqueId}.bigqueryroutine${uniqueId}", + "status": "NOT_FOUND" + } +} + +--- + +POST https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + } +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "etag": "abcdef0123A=", + "lastModifiedTime": "123456789", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + } +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "etag": "abcdef0123A=", + "lastModifiedTime": "123456789", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + } +} + +--- + +DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "reason": "notFound" + } + ], + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "status": "NOT_FOUND" + } +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json&deleteContents=false +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +204 No Content +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/create.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/create.yaml similarity index 94% rename from pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/create.yaml rename to pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/create.yaml index bdef3e9cf1..21deda935e 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/create.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/create.yaml @@ -18,10 +18,9 @@ metadata: name: bigqueryroutine-${uniqueId} spec: datasetRef: - name: bigquerydataset-${uniqueId} + name: bigquerydataset${uniqueId} definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y); - language: SQL projectRef: external: ${projectId} resourceID: bigqueryroutine${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/dependencies.yaml similarity index 81% rename from pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/dependencies.yaml rename to pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/dependencies.yaml index 53064dcef3..739fd20560 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/bigqueryroutineautogen/dependencies.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/dependencies.yaml @@ -1,4 +1,4 @@ -# Copyright 2023 Google LLC +# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 kind: BigQueryDataset metadata: - name: bigquerydataset-${uniqueId} + name: bigquerydataset${uniqueId} spec: - projectRef: - external: ${projectId} - resourceID: bigquerydataset${uniqueId} + location: us-central1 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml new file mode 100644 index 0000000000..21deda935e --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml @@ -0,0 +1,27 @@ +# Copyright 2023 Google LLC +# +# 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. + +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + name: bigqueryroutine-${uniqueId} +spec: + datasetRef: + name: bigquerydataset${uniqueId} + definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + + y); + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + routineType: PROCEDURE diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_bigqueryroutineautogen.golden.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_bigqueryroutineautogen.golden.yaml new file mode 100644 index 0000000000..ec16354a61 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_bigqueryroutineautogen.golden.yaml @@ -0,0 +1,34 @@ +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + annotations: + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/state-into-spec: absent + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 1 + labels: + cnrm-test: "true" + name: bigqueryroutine-${uniqueId} + namespace: ${uniqueId} +spec: + datasetRef: + name: bigquerydataset-${uniqueId} + definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + + y); + language: SQL + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + routineType: PROCEDURE +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + creationTime: "1970-01-01T00:00:00Z" + lastModifiedTime: "1970-01-01T00:00:00Z" + observedGeneration: 1 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml new file mode 100644 index 0000000000..fdb75c6f1b --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml @@ -0,0 +1,40 @@ +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + annotations: + cnrm.cloud.google.com/management-conflict-prevention-policy: none + cnrm.cloud.google.com/state-into-spec: absent + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 1 + labels: + cnrm-test: "true" + name: bigqueryroutine-${uniqueId} + namespace: ${uniqueId} +spec: + arguments: + - argumentKind: FIXED_TYPE + dataType: '{"typeKind":"STRING"}' + name: ssn + datasetRef: + name: bigquerydataset${uniqueId} + definitionBody: SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X') + description: fully configured big query routine + determinismLevel: DETERMINISM_LEVEL_UNSPECIFIED + language: SQL + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + returnType: '{"typeKind":"STRING"}' + routineType: SCALAR_FUNCTION +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + creationTime: "1970-01-01T00:00:00Z" + lastModifiedTime: "1970-01-01T00:00:00Z" + observedGeneration: 1 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log new file mode 100644 index 0000000000..d1e912878d --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log @@ -0,0 +1,400 @@ +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "Not found: Dataset ${projectId}:bigquerydataset${uniqueId}", + "reason": "notFound" + } + ], + "message": "Not found: Dataset ${projectId}:bigquerydataset${uniqueId}", + "status": "NOT_FOUND" + } +} + +--- + +POST https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}" + }, + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "location": "us-central1" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "Not found: Routine ${projectId}:bigquerydataset${uniqueId}.bigqueryroutine${uniqueId}", + "reason": "notFound" + } + ], + "message": "Not found: Routine ${projectId}:bigquerydataset${uniqueId}.bigqueryroutine${uniqueId}", + "status": "NOT_FOUND" + } +} + +--- + +POST https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "arguments": [ + { + "argumentKind": "ANY_TYPE", + "mode": "IN", + "name": "input1" + } + ], + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "description": "fully configured big query routine", + "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", + "importedLibraries": [ + "JAVASCRIPT" + ], + "language": "SQL", + "returnType": { + "typeKind": "FLOAT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "arguments": [ + { + "argumentKind": "ANY_TYPE", + "mode": "IN", + "name": "input1" + } + ], + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "description": "fully configured big query routine", + "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", + "etag": "abcdef0123A=", + "importedLibraries": [ + "JAVASCRIPT" + ], + "language": "SQL", + "lastModifiedTime": "123456789", + "returnType": { + "typeKind": "FLOAT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "arguments": [ + { + "argumentKind": "ANY_TYPE", + "mode": "IN", + "name": "input1" + } + ], + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "description": "fully configured big query routine", + "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", + "etag": "abcdef0123A=", + "importedLibraries": [ + "JAVASCRIPT" + ], + "language": "SQL", + "lastModifiedTime": "123456789", + "returnType": { + "typeKind": "FLOAT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +--- + +DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +404 Not Found +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "reason": "notFound" + } + ], + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "status": "NOT_FOUND" + } +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "access": [ + { + "role": "WRITER", + "specialGroup": "projectWriters" + }, + { + "role": "OWNER", + "specialGroup": "projectOwners" + }, + { + "role": "OWNER", + "userByEmail": "user@google.com" + }, + { + "role": "READER", + "specialGroup": "projectReaders" + } + ], + "creationTime": "123456789", + "datasetReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}" + }, + "etag": "abcdef0123A=", + "id": "000000000000000000000", + "kind": "bigquery#dataset", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "lastModifiedTime": "123456789", + "location": "us-central1", + "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", + "type": "DEFAULT" +} + +--- + +DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}?alt=json&deleteContents=false +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +204 No Content +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 \ No newline at end of file diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/create.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/create.yaml new file mode 100644 index 0000000000..65c756eb70 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/create.yaml @@ -0,0 +1,34 @@ +# Copyright 2023 Google LLC +# +# 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. + +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + name: bigqueryroutine-${uniqueId} +spec: + arguments: + - name: "ssn" + dataType: "{\"typeKind\":\"STRING\"}" + argumentKind: "FIXED_TYPE" + datasetRef: + name: bigquerydataset${uniqueId} + definitionBody: SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X') + description: "fully configured big query routine" + determinismLevel: DETERMINISM_LEVEL_UNSPECIFIED + language: SQL + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + returnType: "{\"typeKind\":\"STRING\"}" + routineType: SCALAR_FUNCTION diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/dependencies.yaml new file mode 100644 index 0000000000..739fd20560 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/dependencies.yaml @@ -0,0 +1,20 @@ +# Copyright 2024 Google LLC +# +# 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. + +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryDataset +metadata: + name: bigquerydataset${uniqueId} +spec: + location: us-central1 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml new file mode 100644 index 0000000000..65c756eb70 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml @@ -0,0 +1,34 @@ +# Copyright 2023 Google LLC +# +# 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. + +apiVersion: bigquery.cnrm.cloud.google.com/v1beta1 +kind: BigQueryRoutine +metadata: + name: bigqueryroutine-${uniqueId} +spec: + arguments: + - name: "ssn" + dataType: "{\"typeKind\":\"STRING\"}" + argumentKind: "FIXED_TYPE" + datasetRef: + name: bigquerydataset${uniqueId} + definitionBody: SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X') + description: "fully configured big query routine" + determinismLevel: DETERMINISM_LEVEL_UNSPECIFIED + language: SQL + projectRef: + external: ${projectId} + resourceID: bigqueryroutine${uniqueId} + returnType: "{\"typeKind\":\"STRING\"}" + routineType: SCALAR_FUNCTION From d0c76a8d80579e4618455a9b060356b4aa90b371 Mon Sep 17 00:00:00 2001 From: xiaoweim Date: Tue, 5 Nov 2024 00:02:18 +0000 Subject: [PATCH 2/4] add real GCP log --- .../basicbigqueryroutine/_http.log | 30 +++----- .../fullybigqueryroutine/_http.log | 72 +++++++------------ 2 files changed, 38 insertions(+), 64 deletions(-) diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log index 5024b2b3ec..f036677573 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log @@ -143,6 +143,7 @@ X-Xss-Protection: 0 }, "lastModifiedTime": "123456789", "location": "us-central1", + "maxTimeTravelHours": "168", "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", "type": "DEFAULT" } @@ -191,7 +192,8 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" - } + }, + "routineType": "PROCEDURE" } 200 OK @@ -209,12 +211,14 @@ X-Xss-Protection: 0 "creationTime": "123456789", "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", "etag": "abcdef0123A=", + "language": "SQL", "lastModifiedTime": "123456789", "routineReference": { "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" - } + }, + "routineType": "PROCEDURE" } --- @@ -238,12 +242,14 @@ X-Xss-Protection: 0 "creationTime": "123456789", "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", "etag": "abcdef0123A=", + "language": "SQL", "lastModifiedTime": "123456789", "routineReference": { "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" - } + }, + "routineType": "PROCEDURE" } --- @@ -252,8 +258,7 @@ DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/dataset Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager -404 Not Found -Cache-Control: private +204 No Content Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -263,20 +268,6 @@ X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Xss-Protection: 0 -{ - "error": { - "code": 404, - "errors": [ - { - "domain": "global", - "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", - "reason": "notFound" - } - ], - "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", - "status": "NOT_FOUND" - } -} --- @@ -328,6 +319,7 @@ X-Xss-Protection: 0 }, "lastModifiedTime": "123456789", "location": "us-central1", + "maxTimeTravelHours": "168", "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", "type": "DEFAULT" } diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log index d1e912878d..65a7847e94 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log @@ -143,6 +143,7 @@ X-Xss-Protection: 0 }, "lastModifiedTime": "123456789", "location": "us-central1", + "maxTimeTravelHours": "168", "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", "type": "DEFAULT" } @@ -188,27 +189,26 @@ User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 t { "arguments": [ { - "argumentKind": "ANY_TYPE", - "mode": "IN", - "name": "input1" + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "ssn" } ], - "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "definitionBody": "SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X')", "description": "fully configured big query routine", "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", - "importedLibraries": [ - "JAVASCRIPT" - ], "language": "SQL", "returnType": { - "typeKind": "FLOAT64" + "typeKind": "STRING" }, "routineReference": { "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" }, - "routineType": "PROCEDURE" + "routineType": "SCALAR_FUNCTION" } 200 OK @@ -225,30 +225,28 @@ X-Xss-Protection: 0 { "arguments": [ { - "argumentKind": "ANY_TYPE", - "mode": "IN", - "name": "input1" + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "ssn" } ], "creationTime": "123456789", - "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "definitionBody": "SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X')", "description": "fully configured big query routine", - "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", "etag": "abcdef0123A=", - "importedLibraries": [ - "JAVASCRIPT" - ], "language": "SQL", "lastModifiedTime": "123456789", "returnType": { - "typeKind": "FLOAT64" + "typeKind": "STRING" }, "routineReference": { "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" }, - "routineType": "PROCEDURE" + "routineType": "SCALAR_FUNCTION" } --- @@ -271,30 +269,28 @@ X-Xss-Protection: 0 { "arguments": [ { - "argumentKind": "ANY_TYPE", - "mode": "IN", - "name": "input1" + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "ssn" } ], "creationTime": "123456789", - "definitionBody": "CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + y);", + "definitionBody": "SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X')", "description": "fully configured big query routine", - "determinismLevel": "DETERMINISM_LEVEL_UNSPECIFIED", "etag": "abcdef0123A=", - "importedLibraries": [ - "JAVASCRIPT" - ], "language": "SQL", "lastModifiedTime": "123456789", "returnType": { - "typeKind": "FLOAT64" + "typeKind": "STRING" }, "routineReference": { "datasetId": "bigquerydataset${uniqueId}", "projectId": "${projectId}", "routineId": "bigqueryroutine${uniqueId}" }, - "routineType": "PROCEDURE" + "routineType": "SCALAR_FUNCTION" } --- @@ -303,8 +299,7 @@ DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/dataset Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager -404 Not Found -Cache-Control: private +204 No Content Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -314,20 +309,6 @@ X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Xss-Protection: 0 -{ - "error": { - "code": 404, - "errors": [ - { - "domain": "global", - "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", - "reason": "notFound" - } - ], - "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", - "status": "NOT_FOUND" - } -} --- @@ -379,6 +360,7 @@ X-Xss-Protection: 0 }, "lastModifiedTime": "123456789", "location": "us-central1", + "maxTimeTravelHours": "168", "selfLink": "https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/bigquerydataset${uniqueId}", "type": "DEFAULT" } From db753bffa2d970c6d520b505ddeea25f5abee147 Mon Sep 17 00:00:00 2001 From: xiaoweim Date: Tue, 5 Nov 2024 00:04:42 +0000 Subject: [PATCH 3/4] add mock GCP log --- .../basicbigqueryroutine/_http.log | 17 ++++++++++++++++- .../fullybigqueryroutine/_http.log | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log index f036677573..8a1995c6f7 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log @@ -258,7 +258,8 @@ DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/dataset Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager -204 No Content +404 Not Found +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -268,6 +269,20 @@ X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Xss-Protection: 0 +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "reason": "notFound" + } + ], + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "status": "NOT_FOUND" + } +} --- diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log index 65a7847e94..aa6301acd4 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log @@ -299,7 +299,8 @@ DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/dataset Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager -204 No Content +404 Not Found +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -309,6 +310,20 @@ X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Xss-Protection: 0 +{ + "error": { + "code": 404, + "errors": [ + { + "domain": "global", + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "reason": "notFound" + } + ], + "message": "dataset \"projects/${projectId}/datasets/bigquerydataset${uniqueId}/routines/bigqueryroutine${uniqueId}\" not found", + "status": "NOT_FOUND" + } +} --- From c6fad4a002606577f0a3ac74421b3464da588677 Mon Sep 17 00:00:00 2001 From: xiaoweim Date: Thu, 7 Nov 2024 06:04:01 +0000 Subject: [PATCH 4/4] update the update.yaml files --- ...ed_object_basicbigqueryroutine.golden.yaml | 8 +- .../basicbigqueryroutine/_http.log | 73 +++++++++++ .../basicbigqueryroutine/update.yaml | 4 +- ...ed_object_fullybigqueryroutine.golden.yaml | 14 +-- .../fullybigqueryroutine/_http.log | 115 ++++++++++++++++++ .../fullybigqueryroutine/update.yaml | 10 +- 6 files changed, 206 insertions(+), 18 deletions(-) diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml index 5372b85c84..d28d176f47 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_generated_object_basicbigqueryroutine.golden.yaml @@ -7,7 +7,7 @@ metadata: finalizers: - cnrm.cloud.google.com/finalizer - cnrm.cloud.google.com/deletion-defender - generation: 1 + generation: 2 labels: cnrm-test: "true" name: bigqueryroutine-${uniqueId} @@ -15,8 +15,8 @@ metadata: spec: datasetRef: name: bigquerydataset${uniqueId} - definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x - + y); + definitionBody: CREATE FUNCTION Sub(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + - y); projectRef: external: ${projectId} resourceID: bigqueryroutine${uniqueId} @@ -30,4 +30,4 @@ status: type: Ready creationTime: "1970-01-01T00:00:00Z" lastModifiedTime: "1970-01-01T00:00:00Z" - observedGeneration: 1 + observedGeneration: 2 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log index 8a1995c6f7..7dcf49fdca 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/_http.log @@ -254,6 +254,79 @@ X-Xss-Protection: 0 --- +PUT https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "definitionBody": "CREATE FUNCTION Sub(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x - y);", + "language": "SQL", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Sub(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x - y);", + "etag": "abcdef0123A=", + "language": "SQL", + "lastModifiedTime": "123456789", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "creationTime": "123456789", + "definitionBody": "CREATE FUNCTION Sub(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x - y);", + "etag": "abcdef0123A=", + "language": "SQL", + "lastModifiedTime": "123456789", + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "PROCEDURE" +} + +--- + DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml index 21deda935e..6cc8c4bd7c 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/basicbigqueryroutine/update.yaml @@ -19,8 +19,8 @@ metadata: spec: datasetRef: name: bigquerydataset${uniqueId} - definitionBody: CREATE FUNCTION Add(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x - + y); + definitionBody: CREATE FUNCTION Sub(x FLOAT64, y FLOAT64) RETURNS FLOAT64 AS (x + - y); projectRef: external: ${projectId} resourceID: bigqueryroutine${uniqueId} diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml index fdb75c6f1b..84b6564ffe 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_generated_object_fullybigqueryroutine.golden.yaml @@ -7,7 +7,7 @@ metadata: finalizers: - cnrm.cloud.google.com/finalizer - cnrm.cloud.google.com/deletion-defender - generation: 1 + generation: 2 labels: cnrm-test: "true" name: bigqueryroutine-${uniqueId} @@ -16,17 +16,17 @@ spec: arguments: - argumentKind: FIXED_TYPE dataType: '{"typeKind":"STRING"}' - name: ssn + name: xyz datasetRef: name: bigquerydataset${uniqueId} - definitionBody: SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X') - description: fully configured big query routine - determinismLevel: DETERMINISM_LEVEL_UNSPECIFIED + definitionBody: SAFE.REGEXP_REPLACE(xyz, '[0-9]', 'X') + description: fully configured big query routine updated + determinismLevel: NOT_DETERMINISTIC language: SQL projectRef: external: ${projectId} resourceID: bigqueryroutine${uniqueId} - returnType: '{"typeKind":"STRING"}' + returnType: '{"typeKind":"INT64"}' routineType: SCALAR_FUNCTION status: conditions: @@ -37,4 +37,4 @@ status: type: Ready creationTime: "1970-01-01T00:00:00Z" lastModifiedTime: "1970-01-01T00:00:00Z" - observedGeneration: 1 + observedGeneration: 2 diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log index aa6301acd4..ddb2628b39 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/_http.log @@ -295,6 +295,121 @@ X-Xss-Protection: 0 --- +PUT https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +{ + "arguments": [ + { + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "xyz" + } + ], + "definitionBody": "SAFE.REGEXP_REPLACE(xyz, '[0-9]', 'X')", + "description": "fully configured big query routine updated", + "determinismLevel": "NOT_DETERMINISTIC", + "language": "SQL", + "returnType": { + "typeKind": "INT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "SCALAR_FUNCTION" +} + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "arguments": [ + { + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "xyz" + } + ], + "creationTime": "123456789", + "definitionBody": "SAFE.REGEXP_REPLACE(xyz, '[0-9]', 'X')", + "description": "fully configured big query routine updated", + "determinismLevel": "NOT_DETERMINISTIC", + "etag": "abcdef0123A=", + "language": "SQL", + "lastModifiedTime": "123456789", + "returnType": { + "typeKind": "INT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "SCALAR_FUNCTION" +} + +--- + +GET https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json +Content-Type: application/json +User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager + +200 OK +Cache-Control: private +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "arguments": [ + { + "argumentKind": "FIXED_TYPE", + "dataType": { + "typeKind": "STRING" + }, + "name": "xyz" + } + ], + "creationTime": "123456789", + "definitionBody": "SAFE.REGEXP_REPLACE(xyz, '[0-9]', 'X')", + "description": "fully configured big query routine updated", + "determinismLevel": "NOT_DETERMINISTIC", + "etag": "abcdef0123A=", + "language": "SQL", + "lastModifiedTime": "123456789", + "returnType": { + "typeKind": "INT64" + }, + "routineReference": { + "datasetId": "bigquerydataset${uniqueId}", + "projectId": "${projectId}", + "routineId": "bigqueryroutine${uniqueId}" + }, + "routineType": "SCALAR_FUNCTION" +} + +--- + DELETE https://bigquery.googleapis.com/bigquery/v2/projects/${projectId}/datasets/${datasetID}/routines/bigqueryroutine${uniqueId}?alt=json Content-Type: application/json User-Agent: Terraform/ (+https://www.terraform.io) Terraform-Plugin-SDK/2.10.1 terraform-provider-google-beta/kcc/controller-manager diff --git a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml index 65c756eb70..b8c1909c61 100644 --- a/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml +++ b/pkg/test/resourcefixture/testdata/basic/bigquery/v1beta1/bigqueryroutine/fullybigqueryroutine/update.yaml @@ -18,17 +18,17 @@ metadata: name: bigqueryroutine-${uniqueId} spec: arguments: - - name: "ssn" + - name: "xyz" dataType: "{\"typeKind\":\"STRING\"}" argumentKind: "FIXED_TYPE" datasetRef: name: bigquerydataset${uniqueId} - definitionBody: SAFE.REGEXP_REPLACE(ssn, '[0-9]', 'X') - description: "fully configured big query routine" - determinismLevel: DETERMINISM_LEVEL_UNSPECIFIED + definitionBody: SAFE.REGEXP_REPLACE(xyz, '[0-9]', 'X') + description: "fully configured big query routine updated" + determinismLevel: NOT_DETERMINISTIC language: SQL projectRef: external: ${projectId} resourceID: bigqueryroutine${uniqueId} - returnType: "{\"typeKind\":\"STRING\"}" + returnType: "{\"typeKind\":\"INT64\"}" routineType: SCALAR_FUNCTION