Skip to content

Commit

Permalink
Fix issue #125 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-mazurkiewicz authored Oct 15, 2024
1 parent 06d7317 commit d7998d2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.13 (unreleased)

- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)

## 0.1.12

- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: |-

# Changelog

## 0.1.13 (unreleased)

- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)

## 0.1.12

- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
Expand Down
1 change: 1 addition & 0 deletions gen/definitions/ip_pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: IP Pool
rest_endpoint: /api/v2/ippool
get_requires_id: true
id_from_query_path: response
get_extra_query_params: "?limit=1000"
doc_category: Network Settings
attributes:
- model_name: ipPoolName
Expand Down
3 changes: 3 additions & 0 deletions gen/templates/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ func (r *{{camelCase .Name}}Resource) Create(ctx context.Context, req resource.C
params += {{$queryParams}}
{{- end}}
{{- end}}
{{- if .GetExtraQueryParams}}
params += "{{.GetExtraQueryParams}}"
{{- end}}
res, err = r.client.Get({{if .GetRestEndpoint}}"{{.GetRestEndpoint}}"{{else}}plan.getPath(){{end}} + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/data_source_catalystcenter_ip_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (d *IPPoolDataSource) Read(ctx context.Context, req datasource.ReadRequest,

tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))
if config.Id.IsNull() && !config.Name.IsNull() {
res, err := d.client.Get(config.getPath())
res, err := d.client.Get(config.getPath() + "?limit=1000")
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve objects, got error: %s", err))
return
Expand All @@ -157,6 +157,7 @@ func (d *IPPoolDataSource) Read(ctx context.Context, req datasource.ReadRequest,

params := ""
params += "/" + url.QueryEscape(config.Id.ValueString())
params += "?limit=1000"
res, err := d.client.Get(config.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/resource_catalystcenter_ip_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (r *IPPoolResource) Create(ctx context.Context, req resource.CreateRequest,
return
}
params = ""
params += "?limit=1000"
res, err = r.client.Get(plan.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
Expand Down Expand Up @@ -182,6 +183,7 @@ func (r *IPPoolResource) Read(ctx context.Context, req resource.ReadRequest, res

params := ""
params += "/" + url.QueryEscape(state.Id.ValueString())
params += "?limit=1000"
res, err := r.client.Get(state.getPath() + params)
if err != nil && strings.Contains(err.Error(), "StatusCode 404") {
resp.State.RemoveResource(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (r *NetworkProfileResource) Create(ctx context.Context, req resource.Create
return
}
params = ""
params += "?populated=true"
res, err = r.client.Get(plan.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object (GET), got error: %s, %s", err, res.String()))
Expand Down
4 changes: 4 additions & 0 deletions templates/guides/changelog.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ description: |-

# Changelog

## 0.1.13 (unreleased)

- Fix issue with catalystcenter_ip_pool forces replacement on `catalystcenter_ip_pool` resource, [link](https://github.com/CiscoDevNet/terraform-provider-catalystcenter/issues/125)

## 0.1.12

- Change default timeout for asynchronous operations to 60 seconds and introduce provider attribute `max_timeout` to set a custom timeout
Expand Down

0 comments on commit d7998d2

Please sign in to comment.