Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/alicloud_fcv3_alias: add new attribute last_modified_time. #7859

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions alicloud/resource_alicloud_fcv3_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func resourceAliCloudFcv3Alias() *schema.Resource {
Required: true,
ForceNew: true,
},
"last_modified_time": {
Type: schema.TypeString,
Computed: true,
},
"version_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -100,9 +104,9 @@ func resourceAliCloudFcv3AliasCreate(d *schema.ResourceData, meta interface{}) e
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)

if err != nil {
return WrapErrorf(err, DefaultErrorMsg, "alicloud_fcv3_alias", action, AlibabaCloudSdkGoERROR)
Expand Down Expand Up @@ -137,6 +141,9 @@ func resourceAliCloudFcv3AliasRead(d *schema.ResourceData, meta interface{}) err
if objectRaw["description"] != nil {
d.Set("description", objectRaw["description"])
}
if objectRaw["lastModifiedTime"] != nil {
d.Set("last_modified_time", objectRaw["lastModifiedTime"])
}
if objectRaw["versionId"] != nil {
d.Set("version_id", objectRaw["versionId"])
}
Expand All @@ -146,7 +153,6 @@ func resourceAliCloudFcv3AliasRead(d *schema.ResourceData, meta interface{}) err

parts := strings.Split(d.Id(), ":")
d.Set("function_name", parts[0])
d.Set("alias_name", parts[1])

return nil
}
Expand All @@ -172,22 +178,19 @@ func resourceAliCloudFcv3AliasUpdate(d *schema.ResourceData, meta interface{}) e

if d.HasChange("description") {
update = true
request["description"] = d.Get("description")
}
if v, ok := d.GetOk("description"); ok || d.HasChange("description") {
request["description"] = v
}

if d.HasChange("version_id") {
update = true
request["versionId"] = d.Get("version_id")
}
if v, ok := d.GetOk("version_id"); ok || d.HasChange("version_id") {
request["versionId"] = v
}

if d.HasChange("additional_version_weight") {
update = true
request["additionalVersionWeight"] = d.Get("additional_version_weight")
}
if v, ok := d.GetOk("additional_version_weight"); ok || d.HasChange("additional_version_weight") {
request["additionalVersionWeight"] = v
}

body = request
if update {
runtime := util.RuntimeOptions{}
Expand All @@ -202,9 +205,9 @@ func resourceAliCloudFcv3AliasUpdate(d *schema.ResourceData, meta interface{}) e
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)
if err != nil {
return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR)
}
Expand All @@ -223,19 +226,17 @@ func resourceAliCloudFcv3AliasDelete(d *schema.ResourceData, meta interface{}) e
var request map[string]interface{}
var response map[string]interface{}
query := make(map[string]*string)
body := make(map[string]interface{})
conn, err := client.NewFcv2Client()
if err != nil {
return WrapError(err)
}
request = make(map[string]interface{})

body = request
runtime := util.RuntimeOptions{}
runtime.SetAutoretry(true)
wait := incrementalWait(3*time.Second, 5*time.Second)
err = resource.Retry(d.Timeout(schema.TimeoutDelete), func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer("2023-03-30"), nil, StringPointer("DELETE"), StringPointer("AK"), StringPointer(action), query, nil, body, &runtime)
response, err = conn.DoRequest(StringPointer("2023-03-30"), nil, StringPointer("DELETE"), StringPointer("AK"), StringPointer(action), query, nil, nil, &runtime)

if err != nil {
if NeedRetry(err) {
Expand All @@ -244,11 +245,14 @@ func resourceAliCloudFcv3AliasDelete(d *schema.ResourceData, meta interface{}) e
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)

if err != nil {
if NotFoundError(err) {
return nil
}
return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR)
}

Expand Down
7 changes: 4 additions & 3 deletions alicloud/service_alicloud_fcv3_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (s *Fcv3ServiceV2) Fcv3FunctionVersionStateRefreshFunc(id string, field str
}

// DescribeFcv3FunctionVersion >>> Encapsulated.

// DescribeFcv3Alias <<< Encapsulated get interface for Fcv3 Alias.

func (s *Fcv3ServiceV2) DescribeFcv3Alias(id string) (object map[string]interface{}, err error) {
Expand Down Expand Up @@ -256,18 +257,18 @@ func (s *Fcv3ServiceV2) DescribeFcv3Alias(id string) (object map[string]interfac
}
return resource.NonRetryableError(err)
}
addDebug(action, response, request)
return nil
})
addDebug(action, response, request)
if err != nil {
if IsExpectedErrors(err, []string{"AliasNotFound"}) {
return object, WrapErrorf(Error(GetNotFoundMessage("Alias", id)), NotFoundMsg, response)
}
addDebug(action, response, request)
return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR)
}
response = response["body"].(map[string]interface{})

return response["body"].(map[string]interface{}), nil
return response, nil
}

func (s *Fcv3ServiceV2) Fcv3AliasStateRefreshFunc(id string, field string, failStates []string) resource.StateRefreshFunc {
Expand Down
7 changes: 1 addition & 6 deletions website/docs/r/fcv3_alias.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ For information about FCV3 Alias and how to use it, see [What is Alias](https://

Basic Usage

<div style="display: block;margin-bottom: 40px;"><div class="oics-button" style="float: right;position: absolute;margin-bottom: 10px;">
<a href="https://api.aliyun.com/api-tools/terraform?resource=alicloud_fcv3_alias&exampleId=964a205d-f3d9-3bda-b718-c780deee06a81557d045&activeTab=example&spm=docs.r.fcv3_alias.0.964a205df3&intl_lang=EN_US" target="_blank">
<img alt="Open in AliCloud" src="https://img.alicdn.com/imgextra/i1/O1CN01hjjqXv1uYUlY56FyX_!!6000000006049-55-tps-254-36.svg" style="max-height: 44px; max-width: 100%;">
</a>
</div></div>

```terraform
variable "name" {
default = "terraform-example"
Expand Down Expand Up @@ -65,6 +59,7 @@ The following arguments are supported:
The following attributes are exported:
* `id` - The ID of the resource supplied above.The value is formulated as `<function_name>:<alias_name>`.
* `create_time` - The creation time of the resource
* `last_modified_time` - (Available since v1.234.0) Last modification time

## Timeouts

Expand Down
Loading