diff --git a/.changelog/15554.txt b/.changelog/15554.txt new file mode 100644 index 0000000000..2407d870eb --- /dev/null +++ b/.changelog/15554.txt @@ -0,0 +1,3 @@ +```release-note:new-resource +`google_saas_runtime_unit_operation` (revert) +``` \ No newline at end of file diff --git a/google-beta/provider/provider_mmv1_resources.go b/google-beta/provider/provider_mmv1_resources.go index 25266488b7..ef2a4fd4ed 100644 --- a/google-beta/provider/provider_mmv1_resources.go +++ b/google-beta/provider/provider_mmv1_resources.go @@ -621,9 +621,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ } // Resources -// Generated resources: 732 +// Generated resources: 731 // Generated IAM resources: 348 -// Total generated resources: 1080 +// Total generated resources: 1079 var generatedResources = map[string]*schema.Resource{ "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), @@ -1532,7 +1532,6 @@ var generatedResources = map[string]*schema.Resource{ "google_saas_runtime_tenant": saasruntime.ResourceSaasRuntimeTenant(), "google_saas_runtime_unit": saasruntime.ResourceSaasRuntimeUnit(), "google_saas_runtime_unit_kind": saasruntime.ResourceSaasRuntimeUnitKind(), - "google_saas_runtime_unit_operation": saasruntime.ResourceSaasRuntimeUnitOperation(), "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), diff --git a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation.go b/google-beta/services/saasruntime/resource_saas_runtime_unit_operation.go deleted file mode 100644 index a6e3b6311f..0000000000 --- a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation.go +++ /dev/null @@ -1,1135 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This code is generated by Magic Modules using the following: -// -// Configuration: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/saasservicemgmt/UnitOperation.yaml -// Template: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/resource.go.tmpl -// -// DO NOT EDIT this file directly. Any changes made to this file will be -// overwritten during the next generation cycle. -// -// ---------------------------------------------------------------------------- - -package saasruntime - -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-plugin-testing/helper/resource" - - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" -) - -func ResourceSaasRuntimeUnitOperation() *schema.Resource { - return &schema.Resource{ - Create: resourceSaasRuntimeUnitOperationCreate, - Read: resourceSaasRuntimeUnitOperationRead, - Update: resourceSaasRuntimeUnitOperationUpdate, - Delete: resourceSaasRuntimeUnitOperationDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSaasRuntimeUnitOperationImport, - }, - - 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.SetAnnotationsDiff, - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Resource ID segment making up resource 'name'. It identifies the resource within its parent collection as described in https://google.aip.dev/122.`, - }, - "unit": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The Unit a given UnitOperation will act upon.`, - }, - "unit_operation_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The ID value for the new unit operation.`, - }, - "annotations": { - Type: schema.TypeMap, - Optional: true, - ForceNew: true, - Description: `Annotations is an unstructured key-value map stored with a resource that -may be set by external tools to store and retrieve arbitrary metadata. -They are not queryable and should be preserved when modifying objects. - -More info: https://kubernetes.io/docs/user-guide/annotations - -**Note**: This field is non-authoritative, and will only manage the annotations present in your configuration. -Please refer to the field 'effective_annotations' for all of the annotations present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "deprovision": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Deprovision is the unit operation that deprovision the underlying -resources represented by a Unit. Can only execute if the Unit is currently -provisioned.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `The labels on the resource, which can be used for categorization. -similar to Kubernetes resource 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}, - }, - "provision": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Provision is the unit operation that provision the underlying resources -represented by a Unit. Can only execute if the Unit is not currently -provisioned.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "input_variables": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Set of input variables. Maximum 100. (optional)`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "variable": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of the variable from actuation configs.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Name of a supported variable type. Supported types are string, int, bool. -Possible values: -STRING -INT -BOOL`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `String encoded value for the variable.`, - }, - }, - }, - }, - "release": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Reference to the Release object to use for the Unit. (optional).`, - }, - }, - }, - }, - "upgrade": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Upgrade is the unit operation that upgrades a provisioned unit, which may -also include the underlying resources represented by a Unit. Can only execute -if the Unit is currently provisioned.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "input_variables": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Set of input variables. Maximum 100. (optional)`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "variable": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of the variable from actuation configs.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Name of a supported variable type. Supported types are string, int, bool. -Possible values: -STRING -INT -BOOL`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `String encoded value for the variable.`, - }, - }, - }, - }, - "release": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Reference to the Release object to use for the Unit. (optional).`, - }, - }, - }, - }, - "conditions": { - Type: schema.TypeList, - Computed: true, - Description: `A set of conditions which indicate the various conditions this resource can -have.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "last_transition_time": { - Type: schema.TypeString, - Computed: true, - Description: `Last time the condition transited from one status to another.`, - }, - "message": { - Type: schema.TypeString, - Computed: true, - Description: `Human readable message indicating details about the last transition.`, - }, - "reason": { - Type: schema.TypeString, - Computed: true, - Description: `Brief reason for the condition's last transition.`, - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: `Status of the condition. -Possible values: -STATUS_UNKNOWN -STATUS_TRUE -STATUS_FALSE`, - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: `Type of the condition. -Possible values: -TYPE_SCHEDULED -TYPE_RUNNING -TYPE_SUCCEEDED -TYPE_CANCELLED`, - }, - }, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the resource was created.`, - }, - "effective_annotations": { - Type: schema.TypeMap, - Computed: true, - ForceNew: true, - Description: `All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "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}, - }, - "engine_state": { - Type: schema.TypeString, - Computed: true, - Description: `The engine state for on-going -deployment engine operation(s). -This field is opaque for external usage.`, - }, - "error_category": { - Type: schema.TypeString, - Computed: true, - Description: `Possible values: -NOT_APPLICABLE -FATAL -RETRIABLE -IGNORABLE -STANDARD`, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `An opaque value that uniquely identifies a version or -generation of a resource. It can be used to confirm that the client -and server agree on the ordering of a resource being written.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `Identifier. The resource name (full URI of the resource) following the standard naming -scheme: - -"projects/{project}/locations/{location}/unitOperations/{unitOperation}"`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `UnitOperationState describes the current state of the unit operation. -Possible values: -UNIT_OPERATION_STATE_UNKNOWN -UNIT_OPERATION_STATE_PENDING -UNIT_OPERATION_STATE_SCHEDULED -UNIT_OPERATION_STATE_RUNNING -UNIT_OPERATION_STATE_SUCCEEDED -UNIT_OPERATION_STATE_FAILED -UNIT_OPERATION_STATE_CANCELLED`, - }, - "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 unique identifier of the resource. UID is unique in the time -and space for this resource within the scope of the service. It is -typically generated by the server on successful creation of a resource -and must not be changed. UID is used to uniquely identify resources -with resource name reuses. This should be a UUID4.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the resource was last updated. Any -change to the resource made by users must refresh this value. -Changes to a resource made by the service should refresh this value.`, - }, - "wait_for_completion": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, wait for the UnitOperation to reach a terminal state (SUCCEEDED, FAILED, CANCELLED) -before completing the apply.`, - Default: true, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSaasRuntimeUnitOperationCreate(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{}) - deprovisionProp, err := expandSaasRuntimeUnitOperationDeprovision(d.Get("deprovision"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("deprovision"); ok || !reflect.DeepEqual(v, deprovisionProp) { - obj["deprovision"] = deprovisionProp - } - provisionProp, err := expandSaasRuntimeUnitOperationProvision(d.Get("provision"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("provision"); !tpgresource.IsEmptyValue(reflect.ValueOf(provisionProp)) && (ok || !reflect.DeepEqual(v, provisionProp)) { - obj["provision"] = provisionProp - } - unitProp, err := expandSaasRuntimeUnitOperationUnit(d.Get("unit"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("unit"); !tpgresource.IsEmptyValue(reflect.ValueOf(unitProp)) && (ok || !reflect.DeepEqual(v, unitProp)) { - obj["unit"] = unitProp - } - upgradeProp, err := expandSaasRuntimeUnitOperationUpgrade(d.Get("upgrade"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("upgrade"); !tpgresource.IsEmptyValue(reflect.ValueOf(upgradeProp)) && (ok || !reflect.DeepEqual(v, upgradeProp)) { - obj["upgrade"] = upgradeProp - } - effectiveAnnotationsProp, err := expandSaasRuntimeUnitOperationEffectiveAnnotations(d.Get("effective_annotations"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_annotations"); !tpgresource.IsEmptyValue(reflect.ValueOf(effectiveAnnotationsProp)) && (ok || !reflect.DeepEqual(v, effectiveAnnotationsProp)) { - obj["annotations"] = effectiveAnnotationsProp - } - effectiveLabelsProp, err := expandSaasRuntimeUnitOperationEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(effectiveLabelsProp)) && (ok || !reflect.DeepEqual(v, effectiveLabelsProp)) { - obj["labels"] = effectiveLabelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SaasRuntimeBasePath}}projects/{{project}}/locations/{{location}}/unitOperations?unitOperationId={{unit_operation_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new UnitOperation: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for UnitOperation: %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 UnitOperation: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - if d.Get("wait_for_completion").(bool) { - log.Printf("[DEBUG] Waiting for UnitOperation %q to reach terminal state", d.Id()) - err := resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError { - url, err := tpgresource.ReplaceVars(d, config, "{{SaasRuntimeBasePath}}projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}") - if err != nil { - return resource.NonRetryableError(err) - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return resource.RetryableError(fmt.Errorf("transient error retrieving UnitOperation state: %s", err)) - } - - state, ok := res["state"].(string) - if !ok { - return resource.RetryableError(fmt.Errorf("UnitOperation %q did not return a state field", d.Id())) - } - - log.Printf("[DEBUG] UnitOperation %q state: %s", d.Id(), state) - - switch state { - case "UNIT_OPERATION_STATE_SUCCEEDED": - return nil - case "UNIT_OPERATION_STATE_FAILED", "UNIT_OPERATION_STATE_CANCELLED": - return resource.NonRetryableError(fmt.Errorf("UnitOperation %q reached terminal failure state: %s", d.Id(), state)) - case "UNIT_OPERATION_STATE_UNKNOWN", "UNIT_OPERATION_STATE_PENDING", "UNIT_OPERATION_STATE_SCHEDULED", "UNIT_OPERATION_STATE_RUNNING": - return resource.RetryableError(fmt.Errorf("UnitOperation %q is still in state %s", d.Id(), state)) - default: - return resource.RetryableError(fmt.Errorf("UnitOperation %q has unexpected state: %s", d.Id(), state)) - } - }) - - if err != nil { - return fmt.Errorf("Error waiting for UnitOperation to reach terminal state: %s", err) - } - } - - log.Printf("[DEBUG] Finished creating UnitOperation %q: %#v", d.Id(), res) - - return resourceSaasRuntimeUnitOperationRead(d, meta) -} - -func resourceSaasRuntimeUnitOperationRead(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, "{{SaasRuntimeBasePath}}projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for UnitOperation: %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("SaasRuntimeUnitOperation %q", d.Id())) - } - - // Explicitly set virtual fields to default values if unset - if _, ok := d.GetOkExists("wait_for_completion"); !ok { - if err := d.Set("wait_for_completion", true); err != nil { - return fmt.Errorf("Error setting wait_for_completion: %s", err) - } - } - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - - if err := d.Set("annotations", flattenSaasRuntimeUnitOperationAnnotations(res["annotations"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("conditions", flattenSaasRuntimeUnitOperationConditions(res["conditions"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("create_time", flattenSaasRuntimeUnitOperationCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("deprovision", flattenSaasRuntimeUnitOperationDeprovision(res["deprovision"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("engine_state", flattenSaasRuntimeUnitOperationEngineState(res["engineState"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("error_category", flattenSaasRuntimeUnitOperationErrorCategory(res["errorCategory"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("etag", flattenSaasRuntimeUnitOperationEtag(res["etag"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("labels", flattenSaasRuntimeUnitOperationLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("name", flattenSaasRuntimeUnitOperationName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("provision", flattenSaasRuntimeUnitOperationProvision(res["provision"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("state", flattenSaasRuntimeUnitOperationState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("uid", flattenSaasRuntimeUnitOperationUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("unit", flattenSaasRuntimeUnitOperationUnit(res["unit"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("update_time", flattenSaasRuntimeUnitOperationUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("upgrade", flattenSaasRuntimeUnitOperationUpgrade(res["upgrade"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("effective_annotations", flattenSaasRuntimeUnitOperationEffectiveAnnotations(res["annotations"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("terraform_labels", flattenSaasRuntimeUnitOperationTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - if err := d.Set("effective_labels", flattenSaasRuntimeUnitOperationEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading UnitOperation: %s", err) - } - - return nil -} - -func resourceSaasRuntimeUnitOperationUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels" and "terraform_labels" are mutable - return resourceSaasRuntimeUnitOperationRead(d, meta) -} - -func resourceSaasRuntimeUnitOperationDelete(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 UnitOperation: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{SaasRuntimeBasePath}}projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_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 UnitOperation %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, "UnitOperation") - } - - log.Printf("[DEBUG] Finished deleting UnitOperation %q: %#v", d.Id(), res) - return nil -} - -func resourceSaasRuntimeUnitOperationImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/unitOperations/(?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}}/unitOperations/{{unit_operation_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Explicitly set virtual fields to default values on import - if err := d.Set("wait_for_completion", true); err != nil { - return nil, fmt.Errorf("Error setting wait_for_completion: %s", err) - } - - return []*schema.ResourceData{d}, nil -} - -func flattenSaasRuntimeUnitOperationAnnotations(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 flattenSaasRuntimeUnitOperationConditions(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{}{ - "last_transition_time": flattenSaasRuntimeUnitOperationConditionsLastTransitionTime(original["lastTransitionTime"], d, config), - "message": flattenSaasRuntimeUnitOperationConditionsMessage(original["message"], d, config), - "reason": flattenSaasRuntimeUnitOperationConditionsReason(original["reason"], d, config), - "status": flattenSaasRuntimeUnitOperationConditionsStatus(original["status"], d, config), - "type": flattenSaasRuntimeUnitOperationConditionsType(original["type"], d, config), - }) - } - return transformed -} -func flattenSaasRuntimeUnitOperationConditionsLastTransitionTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationConditionsMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationConditionsReason(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationConditionsStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationConditionsType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationDeprovision(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenSaasRuntimeUnitOperationEngineState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationErrorCategory(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationLabels(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 flattenSaasRuntimeUnitOperationName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationProvision(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["input_variables"] = - flattenSaasRuntimeUnitOperationProvisionInputVariables(original["inputVariables"], d, config) - transformed["release"] = - flattenSaasRuntimeUnitOperationProvisionRelease(original["release"], d, config) - return []interface{}{transformed} -} -func flattenSaasRuntimeUnitOperationProvisionInputVariables(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": flattenSaasRuntimeUnitOperationProvisionInputVariablesType(original["type"], d, config), - "value": flattenSaasRuntimeUnitOperationProvisionInputVariablesValue(original["value"], d, config), - "variable": flattenSaasRuntimeUnitOperationProvisionInputVariablesVariable(original["variable"], d, config), - }) - } - return transformed -} -func flattenSaasRuntimeUnitOperationProvisionInputVariablesType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationProvisionInputVariablesValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationProvisionInputVariablesVariable(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationProvisionRelease(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUnit(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUpgrade(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["input_variables"] = - flattenSaasRuntimeUnitOperationUpgradeInputVariables(original["inputVariables"], d, config) - transformed["release"] = - flattenSaasRuntimeUnitOperationUpgradeRelease(original["release"], d, config) - return []interface{}{transformed} -} -func flattenSaasRuntimeUnitOperationUpgradeInputVariables(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": flattenSaasRuntimeUnitOperationUpgradeInputVariablesType(original["type"], d, config), - "value": flattenSaasRuntimeUnitOperationUpgradeInputVariablesValue(original["value"], d, config), - "variable": flattenSaasRuntimeUnitOperationUpgradeInputVariablesVariable(original["variable"], d, config), - }) - } - return transformed -} -func flattenSaasRuntimeUnitOperationUpgradeInputVariablesType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUpgradeInputVariablesValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUpgradeInputVariablesVariable(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationUpgradeRelease(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationEffectiveAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSaasRuntimeUnitOperationTerraformLabels(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 flattenSaasRuntimeUnitOperationEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSaasRuntimeUnitOperationDeprovision(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - 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 expandSaasRuntimeUnitOperationProvision(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - 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{}) - - transformedInputVariables, err := expandSaasRuntimeUnitOperationProvisionInputVariables(original["input_variables"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedInputVariables); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["inputVariables"] = transformedInputVariables - } - - transformedRelease, err := expandSaasRuntimeUnitOperationProvisionRelease(original["release"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRelease); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["release"] = transformedRelease - } - - return transformed, nil -} - -func expandSaasRuntimeUnitOperationProvisionInputVariables(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - 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 := expandSaasRuntimeUnitOperationProvisionInputVariablesType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - transformedValue, err := expandSaasRuntimeUnitOperationProvisionInputVariablesValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["value"] = transformedValue - } - - transformedVariable, err := expandSaasRuntimeUnitOperationProvisionInputVariablesVariable(original["variable"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVariable); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["variable"] = transformedVariable - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSaasRuntimeUnitOperationProvisionInputVariablesType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationProvisionInputVariablesValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationProvisionInputVariablesVariable(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationProvisionRelease(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationUnit(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationUpgrade(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - 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{}) - - transformedInputVariables, err := expandSaasRuntimeUnitOperationUpgradeInputVariables(original["input_variables"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedInputVariables); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["inputVariables"] = transformedInputVariables - } - - transformedRelease, err := expandSaasRuntimeUnitOperationUpgradeRelease(original["release"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRelease); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["release"] = transformedRelease - } - - return transformed, nil -} - -func expandSaasRuntimeUnitOperationUpgradeInputVariables(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - 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 := expandSaasRuntimeUnitOperationUpgradeInputVariablesType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - transformedValue, err := expandSaasRuntimeUnitOperationUpgradeInputVariablesValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["value"] = transformedValue - } - - transformedVariable, err := expandSaasRuntimeUnitOperationUpgradeInputVariablesVariable(original["variable"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVariable); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["variable"] = transformedVariable - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSaasRuntimeUnitOperationUpgradeInputVariablesType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationUpgradeInputVariablesValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationUpgradeInputVariablesVariable(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationUpgradeRelease(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSaasRuntimeUnitOperationEffectiveAnnotations(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 expandSaasRuntimeUnitOperationEffectiveLabels(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/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_meta.yaml b/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_meta.yaml deleted file mode 100644 index a85553e118..0000000000 --- a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_meta.yaml +++ /dev/null @@ -1,45 +0,0 @@ -resource: 'google_saas_runtime_unit_operation' -generation_type: 'mmv1' -source_file: 'products/saasservicemgmt/UnitOperation.yaml' -api_service_name: 'saasservicemgmt.googleapis.com' -api_version: 'v1beta1' -api_resource_type_kind: 'UnitOperation' -autogen_status: true -fields: - - api_field: 'annotations' - - api_field: 'conditions.lastTransitionTime' - - api_field: 'conditions.message' - - api_field: 'conditions.reason' - - api_field: 'conditions.status' - - api_field: 'conditions.type' - - api_field: 'createTime' - - api_field: 'deprovision' - - field: 'effective_annotations' - provider_only: true - - field: 'effective_labels' - provider_only: true - - api_field: 'engineState' - - api_field: 'errorCategory' - - api_field: 'etag' - - api_field: 'labels' - - field: 'location' - provider_only: true - - api_field: 'name' - - api_field: 'provision.inputVariables.type' - - api_field: 'provision.inputVariables.value' - - api_field: 'provision.inputVariables.variable' - - api_field: 'provision.release' - - api_field: 'state' - - field: 'terraform_labels' - provider_only: true - - api_field: 'uid' - - api_field: 'unit' - - field: 'unit_operation_id' - provider_only: true - - api_field: 'updateTime' - - api_field: 'upgrade.inputVariables.type' - - api_field: 'upgrade.inputVariables.value' - - api_field: 'upgrade.inputVariables.variable' - - api_field: 'upgrade.release' - - field: 'wait_for_completion' - provider_only: true diff --git a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_test.go b/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_test.go deleted file mode 100644 index 76e019e377..0000000000 --- a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_generated_test.go +++ /dev/null @@ -1,292 +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 saasruntime_test - -import ( - "fmt" - "strings" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" - "github.com/hashicorp/terraform-plugin-testing/terraform" - - "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" -) - -func TestAccSaasRuntimeUnitOperation_saasRuntimeUnitOperationBasicExample(t *testing.T) { - t.Parallel() - acctest.BootstrapIamMembers(t, []acctest.IamMember{ - { - Member: "serviceAccount:service-{project_number}@gcp-sa-saasservicemgmt.iam.gserviceaccount.com", - Role: "roles/saasservicemgmt.serviceAgent", - }, - }) - - context := map[string]interface{}{ - "billing_account": envvar.GetTestBillingAccountFromEnv(t), - "org_id": envvar.GetTestOrgFromEnv(t), - "project": envvar.GetTestProjectFromEnv(), - "project_number": envvar.GetTestProjectNumberFromEnv(), - "random_suffix": acctest.RandString(t, 10), - } - - acctest.VcrTest(t, resource.TestCase{ - PreCheck: func() { acctest.AccTestPreCheck(t) }, - ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), - CheckDestroy: testAccCheckSaasRuntimeUnitOperationDestroyProducer(t), - Steps: []resource.TestStep{ - { - Config: testAccSaasRuntimeUnitOperation_saasRuntimeUnitOperationBasicExample(context), - }, - { - ResourceName: "google_saas_runtime_unit_operation.provision_unit_operation", - ImportState: true, - ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"annotations", "conditions", "error_category", "etag", "labels", "location", "state", "terraform_labels", "unit_operation_id", "update_time"}, - }, - }, - }) -} - -func testAccSaasRuntimeUnitOperation_saasRuntimeUnitOperationBasicExample(context map[string]interface{}) string { - return acctest.Nprintf(` -locals { - location = "us-east1" - tenant_project_id = "tenant%{random_suffix}" -} - -resource "google_saas_runtime_saas" "example_saas" { - provider = google-beta - saas_id = "tf-test-example-saas%{random_suffix}" - location = local.location - - locations { - name = local.location - } -} - -resource "google_saas_runtime_unit_kind" "cluster_unit_kind" { - provider = google-beta - location = local.location - unit_kind_id = "tf-test-vm-unitkind%{random_suffix}" - saas = google_saas_runtime_saas.example_saas.id - default_release = "projects/%{project}/locations/${local.location}/releases/tf-test-example-release%{random_suffix}" -} - -resource "google_saas_runtime_release" "example_release" { - provider = google-beta - location = local.location - release_id = "tf-test-example-release%{random_suffix}" - unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id - blueprint { - package = "us-central1-docker.pkg.dev/ci-test-project-188019/test-repo/tf-test-easysaas-alpha-image@sha256:7992fdbaeaf998ecd31a7f937bb26e38a781ecf49b24857a6176c1e9bfc299ee" - } -} - -resource "google_saas_runtime_unit" "example_unit" { - provider = google-beta - location = local.location - unit_id = "tf-test-example-unit%{random_suffix}" - unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id -} - -resource "google_project" "tenant_project" { - provider = google-beta - project_id = local.tenant_project_id - name = local.tenant_project_id - billing_account = "%{billing_account}" - org_id = "%{org_id}" - deletion_policy = "DELETE" -} - -resource "google_project_service" "saas_services" { - provider = google-beta - project = google_project.tenant_project.project_id - service = "compute.googleapis.com" - disable_dependent_services = true -} - -resource "google_service_account" "actuation_service_account" { - provider = google-beta - account_id = "actuator%{random_suffix}" - display_name = "SaaS Actuation Service Account" -} - -resource "google_project_iam_member" "tenant_config_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/config.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_project_iam_member" "tenant_storage_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/storage.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_project_iam_member" "tenant_compute_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/compute.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_service_account_iam_member" "actuation_token_creator" { - provider = google-beta - service_account_id = google_service_account.actuation_service_account.name - role = "roles/iam.serviceAccountTokenCreator" - member = "serviceAccount:service-%{project_number}@gcp-sa-saasservicemgmt.iam.gserviceaccount.com" -} - -resource "google_saas_runtime_unit_operation" "provision_unit_operation" { - provider = google-beta - depends_on = [google_project_iam_member.tenant_config_admin, google_project_iam_member.tenant_storage_admin, google_project_iam_member.tenant_compute_admin, google_service_account_iam_member.actuation_token_creator, google_project_service.saas_services] - location = local.location - unit_operation_id = "tf-test-provision-unit-operation%{random_suffix}" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - - provision { - release = google_saas_runtime_release.example_release.id - input_variables { - variable = "tenant_project_id" - value = google_project.tenant_project.project_id - type = "STRING" - } - input_variables { - variable = "tenant_project_number" - value = google_project.tenant_project.number - type = "INT" - } - input_variables { - variable = "zone" - value = "us-central1-a" - type = "STRING" - } - input_variables { - variable = "instance_name" - value = "terraform-test-instance" - type = "STRING" - } - input_variables { - variable = "actuation_sa" - value = google_service_account.actuation_service_account.email - type = "STRING" - } - } - labels = { - "label-one" : "foo" - } - annotations = { - "annotation-one" : "bar" - } -} - -resource "google_saas_runtime_unit_operation" "noop_upgrade_unit_operation" { - provider = google-beta - depends_on = [google_saas_runtime_unit_operation.provision_unit_operation] - location = local.location - unit_operation_id = "tf-test-upgrade-unit-operation%{random_suffix}" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - - upgrade { - release = google_saas_runtime_release.example_release.id - input_variables { - variable = "tenant_project_id" - value = google_project.tenant_project.project_id - type = "STRING" - } - input_variables { - variable = "tenant_project_number" - value = google_project.tenant_project.number - type = "INT" - } - input_variables { - variable = "zone" - value = "us-central1-a" - type = "STRING" - } - input_variables { - variable = "instance_name" - value = "terraform-test-instance" - type = "STRING" - } - input_variables { - variable = "actuation_sa" - value = google_service_account.actuation_service_account.email - type = "STRING" - } - } -} - -resource "google_saas_runtime_unit_operation" "deprovision_operation" { - provider = google-beta - depends_on = [google_saas_runtime_unit_operation.noop_upgrade_unit_operation] - location = local.location - unit_operation_id = "tf-test-deprovision-unit-operation%{random_suffix}" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - deprovision {} -} -`, context) -} - -func testAccCheckSaasRuntimeUnitOperationDestroyProducer(t *testing.T) func(s *terraform.State) error { - return func(s *terraform.State) error { - for name, rs := range s.RootModule().Resources { - if rs.Type != "google_saas_runtime_unit_operation" { - continue - } - if strings.HasPrefix(name, "data.") { - continue - } - - config := acctest.GoogleProviderConfig(t) - - url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{SaasRuntimeBasePath}}projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}") - if err != nil { - return err - } - - billingProject := "" - - if config.BillingProject != "" { - billingProject = config.BillingProject - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: config.UserAgent, - }) - if err == nil { - return fmt.Errorf("SaasRuntimeUnitOperation still exists at %s", url) - } - } - - return nil - } -} diff --git a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_sweeper.go b/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_sweeper.go deleted file mode 100644 index 3e7cb3fd1a..0000000000 --- a/google-beta/services/saasruntime/resource_saas_runtime_unit_operation_sweeper.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This code is generated by Magic Modules using the following: -// -// Configuration: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/saasservicemgmt/UnitOperation.yaml -// Template: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/sweeper_file.go.tmpl -// -// DO NOT EDIT this file directly. Any changes made to this file will be -// overwritten during the next generation cycle. -// -// ---------------------------------------------------------------------------- - -package saasruntime - -import ( - "context" - "fmt" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/sweeper" - "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" -) - -func init() { - // Initialize base sweeper object - s := &sweeper.Sweeper{ - Name: "google_saas_runtime_unit_operation", - ListAndAction: listAndActionSaasRuntimeUnitOperation, - DeleteFunction: testSweepSaasRuntimeUnitOperation, - } - - // Register the sweeper - sweeper.AddTestSweepers(s) -} - -func testSweepSaasRuntimeUnitOperation(_ string) error { - return listAndActionSaasRuntimeUnitOperation(deleteResourceSaasRuntimeUnitOperation) -} - -func listAndActionSaasRuntimeUnitOperation(action sweeper.ResourceAction) error { - var lastError error - resourceName := "SaasRuntimeUnitOperation" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - // Prepare configurations to iterate over - var configs []*tpgresource.ResourceDataMock - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - // Default single config - intermediateValues := []map[string]string{ - { - "region": "us-central1", - }, - } - - // Create configs from intermediate values - for _, values := range intermediateValues { - mockConfig := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": envvar.GetTestProjectFromEnv(), - "billing_account": billingId, - }, - } - - // Apply all provided values - for key, value := range values { - mockConfig.FieldsInSchema[key] = value - } - - // Set fallback values for common fields - region, hasRegion := mockConfig.FieldsInSchema["region"].(string) - if !hasRegion { - region = "us-central1" - mockConfig.FieldsInSchema["region"] = region - } - - if _, hasLocation := mockConfig.FieldsInSchema["location"]; !hasLocation { - mockConfig.FieldsInSchema["location"] = region - } - - if _, hasZone := mockConfig.FieldsInSchema["zone"]; !hasZone { - mockConfig.FieldsInSchema["zone"] = region + "-a" - } - - configs = append(configs, mockConfig) - } - - // Process all configurations (either from parent resources or direct substitutions) - for _, mockConfig := range configs { - // Get region from config - region := sweeper.GetFieldOrDefault(mockConfig, "region", "us-central1") - - // Create shared config for this region - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - lastError = err - continue - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - lastError = err - continue - } - - // Prepare list URL - listTemplate := strings.Split("https://saasservicemgmt.googleapis.com/v1beta1/projects/{{project}}/locations/{{location}}/unitOperations", "?")[0] - listUrl, err := tpgresource.ReplaceVars(mockConfig, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - lastError = err - continue - } - - // Log additional info for parent-based resources - log.Printf("[INFO][SWEEPER_LOG] Listing %s resources at %s", resourceName, listUrl) - - 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) - lastError = err - continue - } - - // First try the expected resource key - resourceList, ok := res["unitOperations"] - if ok { - log.Printf("[INFO][SWEEPER_LOG] Found resources under expected key 'unitOperations'") - } else { - // Next, try the common "items" pattern - resourceList, ok = res["items"] - if ok { - log.Printf("[INFO][SWEEPER_LOG] Found resources under standard 'items' key") - } else { - log.Printf("[INFO][SWEEPER_LOG] no resources found") - 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, ok := ri.(map[string]interface{}) - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Item was not a map: %T", ri) - continue - } - - if err := action(config, mockConfig, obj); err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in action: %s", err) - lastError = err - } else { - nonPrefixCount++ - } - } - } - - return lastError -} - -func deleteResourceSaasRuntimeUnitOperation(config *transport_tpg.Config, d *tpgresource.ResourceDataMock, obj map[string]interface{}) error { - var deletionerror error - resourceName := "SaasRuntimeUnitOperation" - 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 fmt.Errorf("%s resource name was nil", resourceName) - } - - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - return nil - } - - deleteTemplate := "https://saasservicemgmt.googleapis.com/v1beta1/projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}" - - url, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - deletionerror = err - } - url = url + 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: url, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", url, err) - deletionerror = err - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - - return deletionerror -} diff --git a/website/docs/r/saas_runtime_unit_operation.html.markdown b/website/docs/r/saas_runtime_unit_operation.html.markdown deleted file mode 100644 index 6f9f4537e7..0000000000 --- a/website/docs/r/saas_runtime_unit_operation.html.markdown +++ /dev/null @@ -1,477 +0,0 @@ ---- -# ---------------------------------------------------------------------------- -# -# *** AUTO GENERATED CODE *** Type: MMv1 *** -# -# ---------------------------------------------------------------------------- -# -# This code is generated by Magic Modules using the following: -# -# Configuration: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/saasservicemgmt/UnitOperation.yaml -# Template: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/resource.html.markdown.tmpl -# -# DO NOT EDIT this file directly. Any changes made to this file will be -# overwritten during the next generation cycle. -# -# ---------------------------------------------------------------------------- -subcategory: "SaaS Runtime" -description: |- - A UnitOperation encapsulates the intent to change or interact with a Unit. ---- - -# google_saas_runtime_unit_operation - -A UnitOperation encapsulates the intent to change or interact with a Unit. Operations such as provisioning, upgrading, or deprovisioning a Unit are triggered by creating a UnitOperation resource. - - - -## Example Usage - Saas Runtime Unit Operation Basic - - -```hcl -locals { - location = "us-east1" - tenant_project_id = "tenant" -} - -resource "google_saas_runtime_saas" "example_saas" { - provider = google-beta - saas_id = "example-saas" - location = local.location - - locations { - name = local.location - } -} - -resource "google_saas_runtime_unit_kind" "cluster_unit_kind" { - provider = google-beta - location = local.location - unit_kind_id = "vm-unitkind" - saas = google_saas_runtime_saas.example_saas.id - default_release = "projects/my-project-name/locations/${local.location}/releases/example-release" -} - -resource "google_saas_runtime_release" "example_release" { - provider = google-beta - location = local.location - release_id = "example-release" - unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id - blueprint { - package = "us-central1-docker.pkg.dev/ci-test-project-188019/test-repo/tf-test-easysaas-alpha-image@sha256:7992fdbaeaf998ecd31a7f937bb26e38a781ecf49b24857a6176c1e9bfc299ee" - } -} - -resource "google_saas_runtime_unit" "example_unit" { - provider = google-beta - location = local.location - unit_id = "example-unit" - unit_kind = google_saas_runtime_unit_kind.cluster_unit_kind.id -} - -resource "google_project" "tenant_project" { - provider = google-beta - project_id = local.tenant_project_id - name = local.tenant_project_id - billing_account = "000000-0000000-0000000-000000" - org_id = "123456789" - deletion_policy = "DELETE" -} - -resource "google_project_service" "saas_services" { - provider = google-beta - project = google_project.tenant_project.project_id - service = "compute.googleapis.com" - disable_dependent_services = true -} - -resource "google_service_account" "actuation_service_account" { - provider = google-beta - account_id = "actuator" - display_name = "SaaS Actuation Service Account" -} - -resource "google_project_iam_member" "tenant_config_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/config.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_project_iam_member" "tenant_storage_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/storage.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_project_iam_member" "tenant_compute_admin" { - provider = google-beta - project = google_project.tenant_project.project_id - role = "roles/compute.admin" - member = "serviceAccount:${google_service_account.actuation_service_account.email}" -} - -resource "google_service_account_iam_member" "actuation_token_creator" { - provider = google-beta - service_account_id = google_service_account.actuation_service_account.name - role = "roles/iam.serviceAccountTokenCreator" - member = "serviceAccount:service-1111111111111@gcp-sa-saasservicemgmt.iam.gserviceaccount.com" -} - -resource "google_saas_runtime_unit_operation" "provision_unit_operation" { - provider = google-beta - depends_on = [google_project_iam_member.tenant_config_admin, google_project_iam_member.tenant_storage_admin, google_project_iam_member.tenant_compute_admin, google_service_account_iam_member.actuation_token_creator, google_project_service.saas_services] - location = local.location - unit_operation_id = "provision-unit-operation" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - - provision { - release = google_saas_runtime_release.example_release.id - input_variables { - variable = "tenant_project_id" - value = google_project.tenant_project.project_id - type = "STRING" - } - input_variables { - variable = "tenant_project_number" - value = google_project.tenant_project.number - type = "INT" - } - input_variables { - variable = "zone" - value = "us-central1-a" - type = "STRING" - } - input_variables { - variable = "instance_name" - value = "terraform-test-instance" - type = "STRING" - } - input_variables { - variable = "actuation_sa" - value = google_service_account.actuation_service_account.email - type = "STRING" - } - } - labels = { - "label-one" : "foo" - } - annotations = { - "annotation-one" : "bar" - } -} - -resource "google_saas_runtime_unit_operation" "noop_upgrade_unit_operation" { - provider = google-beta - depends_on = [google_saas_runtime_unit_operation.provision_unit_operation] - location = local.location - unit_operation_id = "upgrade-unit-operation" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - - upgrade { - release = google_saas_runtime_release.example_release.id - input_variables { - variable = "tenant_project_id" - value = google_project.tenant_project.project_id - type = "STRING" - } - input_variables { - variable = "tenant_project_number" - value = google_project.tenant_project.number - type = "INT" - } - input_variables { - variable = "zone" - value = "us-central1-a" - type = "STRING" - } - input_variables { - variable = "instance_name" - value = "terraform-test-instance" - type = "STRING" - } - input_variables { - variable = "actuation_sa" - value = google_service_account.actuation_service_account.email - type = "STRING" - } - } -} - -resource "google_saas_runtime_unit_operation" "deprovision_operation" { - provider = google-beta - depends_on = [google_saas_runtime_unit_operation.noop_upgrade_unit_operation] - location = local.location - unit_operation_id = "deprovision-unit-operation" - unit = google_saas_runtime_unit.example_unit.id - wait_for_completion = true - deprovision {} -} -``` - -## Argument Reference - -The following arguments are supported: - - -* `unit` - - (Required) - The Unit a given UnitOperation will act upon. - -* `location` - - (Required) - Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122. - -* `unit_operation_id` - - (Required) - The ID value for the new unit operation. - - -* `annotations` - - (Optional) - Annotations is an unstructured key-value map stored with a resource that - may be set by external tools to store and retrieve arbitrary metadata. - They are not queryable and should be preserved when modifying objects. - More info: https://kubernetes.io/docs/user-guide/annotations - **Note**: This field is non-authoritative, and will only manage the annotations present in your configuration. - Please refer to the field `effective_annotations` for all of the annotations present on the resource. - -* `deprovision` - - (Optional) - Deprovision is the unit operation that deprovision the underlying - resources represented by a Unit. Can only execute if the Unit is currently - provisioned. - -* `labels` - - (Optional) - The labels on the resource, which can be used for categorization. - similar to Kubernetes resource 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. - -* `provision` - - (Optional) - Provision is the unit operation that provision the underlying resources - represented by a Unit. Can only execute if the Unit is not currently - provisioned. - Structure is [documented below](#nested_provision). - -* `upgrade` - - (Optional) - Upgrade is the unit operation that upgrades a provisioned unit, which may - also include the underlying resources represented by a Unit. Can only execute - if the Unit is currently provisioned. - Structure is [documented below](#nested_upgrade). - -* `project` - (Optional) The ID of the project in which the resource belongs. - If it is not provided, the provider project is used. - -* `wait_for_completion` - (Optional) If true, wait for the UnitOperation to reach a terminal state (SUCCEEDED, FAILED, CANCELLED) -before completing the apply. - - - -The `provision` block supports: - -* `input_variables` - - (Optional) - Set of input variables. Maximum 100. (optional) - Structure is [documented below](#nested_provision_input_variables). - -* `release` - - (Optional) - Reference to the Release object to use for the Unit. (optional). - - -The `input_variables` block supports: - -* `type` - - (Optional) - Name of a supported variable type. Supported types are string, int, bool. - Possible values: - STRING - INT - BOOL - -* `value` - - (Optional) - String encoded value for the variable. - -* `variable` - - (Required) - Name of the variable from actuation configs. - -The `upgrade` block supports: - -* `input_variables` - - (Optional) - Set of input variables. Maximum 100. (optional) - Structure is [documented below](#nested_upgrade_input_variables). - -* `release` - - (Optional) - Reference to the Release object to use for the Unit. (optional). - - -The `input_variables` block supports: - -* `type` - - (Optional) - Name of a supported variable type. Supported types are string, int, bool. - Possible values: - STRING - INT - BOOL - -* `value` - - (Optional) - String encoded value for the variable. - -* `variable` - - (Required) - Name of the variable from actuation configs. - -## Attributes Reference - -In addition to the arguments listed above, the following computed attributes are exported: - -* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}` - -* `conditions` - - A set of conditions which indicate the various conditions this resource can - have. - Structure is [documented below](#nested_conditions). - -* `create_time` - - The timestamp when the resource was created. - -* `engine_state` - - The engine state for on-going - deployment engine operation(s). - This field is opaque for external usage. - -* `error_category` - - Possible values: - NOT_APPLICABLE - FATAL - RETRIABLE - IGNORABLE - STANDARD - -* `etag` - - An opaque value that uniquely identifies a version or - generation of a resource. It can be used to confirm that the client - and server agree on the ordering of a resource being written. - -* `name` - - Identifier. The resource name (full URI of the resource) following the standard naming - scheme: - "projects/{project}/locations/{location}/unitOperations/{unitOperation}" - -* `state` - - UnitOperationState describes the current state of the unit operation. - Possible values: - UNIT_OPERATION_STATE_UNKNOWN - UNIT_OPERATION_STATE_PENDING - UNIT_OPERATION_STATE_SCHEDULED - UNIT_OPERATION_STATE_RUNNING - UNIT_OPERATION_STATE_SUCCEEDED - UNIT_OPERATION_STATE_FAILED - UNIT_OPERATION_STATE_CANCELLED - -* `uid` - - The unique identifier of the resource. UID is unique in the time - and space for this resource within the scope of the service. It is - typically generated by the server on successful creation of a resource - and must not be changed. UID is used to uniquely identify resources - with resource name reuses. This should be a UUID4. - -* `update_time` - - The timestamp when the resource was last updated. Any - change to the resource made by users must refresh this value. - Changes to a resource made by the service should refresh this value. - -* `effective_annotations` - - All of annotations (key/value pairs) present on the resource in GCP, including the annotations configured through Terraform, other clients and services. - -* `terraform_labels` - - The combination of labels configured directly on the resource - and default labels configured on the provider. - -* `effective_labels` - - All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. - - -The `conditions` block contains: - -* `last_transition_time` - - (Output) - Last time the condition transited from one status to another. - -* `message` - - (Output) - Human readable message indicating details about the last transition. - -* `reason` - - (Output) - Brief reason for the condition's last transition. - -* `status` - - (Output) - Status of the condition. - Possible values: - STATUS_UNKNOWN - STATUS_TRUE - STATUS_FALSE - -* `type` - - (Output) - Type of the condition. - Possible values: - TYPE_SCHEDULED - TYPE_RUNNING - TYPE_SUCCEEDED - TYPE_CANCELLED - -## Timeouts - -This resource provides the following -[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: - -- `create` - Default is 20 minutes. -- `update` - Default is 20 minutes. -- `delete` - Default is 20 minutes. - -## Import - - -UnitOperation can be imported using any of these accepted formats: - -* `projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}` -* `{{project}}/{{location}}/{{unit_operation_id}}` -* `{{location}}/{{unit_operation_id}}` - - -In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import UnitOperation using one of the formats above. For example: - -```tf -import { - id = "projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}}" - to = google_saas_runtime_unit_operation.default -} -``` - -When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), UnitOperation can be imported using one of the formats above. For example: - -``` -$ terraform import google_saas_runtime_unit_operation.default projects/{{project}}/locations/{{location}}/unitOperations/{{unit_operation_id}} -$ terraform import google_saas_runtime_unit_operation.default {{project}}/{{location}}/{{unit_operation_id}} -$ terraform import google_saas_runtime_unit_operation.default {{location}}/{{unit_operation_id}} -``` - -## User Project Overrides - -This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).