Skip to content

Commit 5043bd1

Browse files
Colab runtime template (#12706)
[upstream:9549e70b89fd49a2f06603be2ca855e911172676] Signed-off-by: Modular Magician <[email protected]>
1 parent 2f8beb1 commit 5043bd1

13 files changed

+1895
-2
lines changed

.changelog/12706.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_colab_runtime_template`
3+
```

google-beta/fwmodels/provider_model.go

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type ProviderModel struct {
6868
CloudRunV2CustomEndpoint types.String `tfsdk:"cloud_run_v2_custom_endpoint"`
6969
CloudSchedulerCustomEndpoint types.String `tfsdk:"cloud_scheduler_custom_endpoint"`
7070
CloudTasksCustomEndpoint types.String `tfsdk:"cloud_tasks_custom_endpoint"`
71+
ColabCustomEndpoint types.String `tfsdk:"colab_custom_endpoint"`
7172
ComposerCustomEndpoint types.String `tfsdk:"composer_custom_endpoint"`
7273
ComputeCustomEndpoint types.String `tfsdk:"compute_custom_endpoint"`
7374
ContainerAnalysisCustomEndpoint types.String `tfsdk:"container_analysis_custom_endpoint"`

google-beta/fwprovider/framework_provider.go

+6
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
389389
transport_tpg.CustomEndpointValidator(),
390390
},
391391
},
392+
"colab_custom_endpoint": &schema.StringAttribute{
393+
Optional: true,
394+
Validators: []validator.String{
395+
transport_tpg.CustomEndpointValidator(),
396+
},
397+
},
392398
"composer_custom_endpoint": &schema.StringAttribute{
393399
Optional: true,
394400
Validators: []validator.String{

google-beta/provider/provider.go

+6
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ func Provider() *schema.Provider {
338338
Optional: true,
339339
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
340340
},
341+
"colab_custom_endpoint": {
342+
Type: schema.TypeString,
343+
Optional: true,
344+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
345+
},
341346
"composer_custom_endpoint": {
342347
Type: schema.TypeString,
343348
Optional: true,
@@ -1108,6 +1113,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
11081113
config.CloudRunV2BasePath = d.Get("cloud_run_v2_custom_endpoint").(string)
11091114
config.CloudSchedulerBasePath = d.Get("cloud_scheduler_custom_endpoint").(string)
11101115
config.CloudTasksBasePath = d.Get("cloud_tasks_custom_endpoint").(string)
1116+
config.ColabBasePath = d.Get("colab_custom_endpoint").(string)
11111117
config.ComposerBasePath = d.Get("composer_custom_endpoint").(string)
11121118
config.ComputeBasePath = d.Get("compute_custom_endpoint").(string)
11131119
config.ContainerAnalysisBasePath = d.Get("container_analysis_custom_endpoint").(string)

google-beta/provider/provider_mmv1_resources.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudrunv2"
4343
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudscheduler"
4444
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/cloudtasks"
45+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/colab"
4546
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/composer"
4647
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/compute"
4748
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/containeranalysis"
@@ -516,9 +517,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
516517
}
517518

518519
// Resources
519-
// Generated resources: 585
520+
// Generated resources: 586
520521
// Generated IAM resources: 294
521-
// Total generated resources: 879
522+
// Total generated resources: 880
522523
var generatedResources = map[string]*schema.Resource{
523524
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
524525
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -710,6 +711,7 @@ var generatedResources = map[string]*schema.Resource{
710711
"google_cloud_tasks_queue_iam_binding": tpgiamresource.ResourceIamBinding(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc),
711712
"google_cloud_tasks_queue_iam_member": tpgiamresource.ResourceIamMember(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc),
712713
"google_cloud_tasks_queue_iam_policy": tpgiamresource.ResourceIamPolicy(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc),
714+
"google_colab_runtime_template": colab.ResourceColabRuntimeTemplate(),
713715
"google_composer_user_workloads_config_map": composer.ResourceComposerUserWorkloadsConfigMap(),
714716
"google_compute_address": compute.ResourceComputeAddress(),
715717
"google_compute_autoscaler": compute.ResourceComputeAutoscaler(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package colab
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
28+
)
29+
30+
type ColabOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *ColabOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.ColabBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createColabWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ColabOperationWaiter, error) {
54+
w := &ColabOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func ColabOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createColabWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func ColabOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createColabWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)