feat(gcp-resources): Add Vertex-AI#5762
Conversation
This PR has the following changes to source plugin(s) tables:
|
dfdc686 to
2edc650
Compare
2edc650 to
369a9f3
Compare
369a9f3 to
35db1f7
Compare
|
|
| ) | ||
|
|
||
| func init() { | ||
| resources := []*Resource{ |
There was a problem hiding this comment.
This is the bulk of the PR, the other are changes to support listing locations before listing the actual resources.
These are the locations.*.list top level resources from https://cloud.google.com/vertex-ai/docs/reference/rest.
The resources to list the locations are generated based on these.
To get the locations we need to use the specific client for that resource, for example (&aiplatform.JobClient{}).ListLocations != (&aiplatform.DatasetClient{}).ListLocations
| gcpClient, err := {{.Service}}.{{.NewFunctionName}}(ctx, c.ClientOptions...) | ||
| {{ if .ClientOptions }} | ||
| clientOptions := c.ClientOptions | ||
| clientOptions = append([]option.ClientOption{ {{ range .ClientOptions }}{{.}},{{end}} }, clientOptions...) |
There was a problem hiding this comment.
We prepend the options, otherwise the tests won't be able to override the endpoint URL
projects.locations.*.list
projects.locations.*.listprojects.locations.*.list
35db1f7 to
cdd90a0
Compare
4ca074f to
9b8c448
Compare
66d5d42 to
863ced8
Compare
| } | ||
|
|
||
| func isFieldMockable(field reflect.StructField) bool { | ||
| nonMockables := []any{&structpb.Value{}, &structpb.Struct{}, &pb.Model{}, &pb.PipelineJob_RuntimeConfig{}} |
There was a problem hiding this comment.
Faker can't mock these as we need to set the fields in a specific way so they can be MarshalJSONed
| return responseHasNextPage | ||
| } | ||
|
|
||
| func generateMockTestData(r *recipes.Resource) { |
There was a problem hiding this comment.
This function creates the data necessary to mock the relations gRPC server calls.
We create a server implementation with all the List* methods, then register it.
See example in https://github.com/erezrokah/cloudquery/blob/863ced86bda2266a3d076b98ecd2f70ac1d23403/plugins/source/gcp/resources/services/aiplatform/job_locations_mock_test.go#L44
There was a problem hiding this comment.
I think we can use this approach to get all list functions of a client to remove some boilerplate. I'll look into it separately
|
|
||
| locationSubService := getLocationsServiceName(resource.NewFunction) + "_locations" | ||
| locationResource := locationsMap[locationSubService] | ||
| if locationResource == nil { |
There was a problem hiding this comment.
We need a location resource for all the resources under it, for example JobClient.ListLocations will allow us to list all resources under JobClient.
That's the reason need to check for an existing one, and append the resource as a relation (e.g. JobClient.ListLocations resource we have all relevant List* resources as relations)
| // NameTransformer custom name transformer for resource | ||
| NameTransformer func(field reflect.StructField) (string, error) | ||
| // ClientOptions is a list of options to pass to the client | ||
| ClientOptions []string |
There was a problem hiding this comment.
We need ClientOptions so we can override the endpoint
| ClientOptions []string | ||
| // IgnoreInTestsColumns is a list of columns to ignore in tests | ||
| IgnoreInTestsColumns []string | ||
| ParentFilterFunc string |
There was a problem hiding this comment.
Apparently ListLocations returns invalid locations us and eu that can't be used to list sub resources, so we need to filter them. The function itself is manually written
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
d4a1b66 to
12ac6f8
Compare
12ac6f8 to
1c95cac
Compare
1c95cac to
d8c5d0a
Compare
projects.locations.*.listdb15807 to
fe62993
Compare
4fc1b6d to
d4f62f4
Compare
🤖 I have created a release *beep* *boop* --- ## [5.4.0](plugins-source-gcp-v5.3.1...plugins-source-gcp-v5.4.0) (2023-01-03) ### Features * **gcp-codegen:** Make ListFunction optional ([#5971](#5971)) ([5717f05](5717f05)) * **gcp-resources:** Add AppEngine resources ([#5972](#5972)) ([d6b6c6a](d6b6c6a)) * **gcp-resources:** Add Artifact Registry ([#6020](#6020)) ([76faa06](76faa06)) * **gcp-resources:** Add Bare Metal Solution ([#6044](#6044)) ([9a80b27](9a80b27)) * **gcp-resources:** Add Batch ([#6128](#6128)) ([43cd3be](43cd3be)) * **gcp-resources:** Add BeyondCorp ([#6133](#6133)) ([48aafd0](48aafd0)) * **gcp-resources:** Add Vertex-AI ([#5762](#5762)) ([d22b69d](d22b69d)) * **gcp:** Auto generate services list ([#5961](#5961)) ([0467de5](0467de5)) ### Bug Fixes * **deps:** Update google.golang.org/genproto digest to f9683d7 ([#6170](#6170)) ([0df29be](0df29be)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.14.0 ([#6025](#6025)) ([35b2cfc](35b2cfc)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.15.0 ([#6071](#6071)) ([684b525](684b525)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.15.1 ([#6079](#6079)) ([650659c](650659c)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.16.0 ([#6098](#6098)) ([7bacdf3](7bacdf3)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.16.1 ([#6214](#6214)) ([53b2415](53b2415)) * **deps:** Update module github.com/cloudquery/plugin-sdk to v1.17.0 ([#6256](#6256)) ([b19f6cd](b19f6cd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Summary
PR to add Vertex-AI resources.
Those require:
Caveats
Some API calls fail out of the box, but that happens to

gcloudtoo 😕 I filtered these locations manually for now