From 5d647e05be790cb63b810c35d42bfcdfb1ebbb28 Mon Sep 17 00:00:00 2001 From: Sean O'Brien Date: Tue, 4 Feb 2025 16:41:34 -0600 Subject: [PATCH 1/2] Fix case-sensitive API calls and use pointer slices. --- internal/provider/author_data_source.go | 8 +++- internal/provider/author_resource.go | 8 ++-- internal/provider/authors_data_source.go | 14 +++--- .../custom_format_condition_data_source.go | 14 +++++- .../provider/custom_format_data_source.go | 8 +++- internal/provider/custom_format_resource.go | 15 ++++--- .../provider/custom_formats_data_source.go | 15 ++++--- .../provider/delay_profile_data_source.go | 8 +++- internal/provider/delay_profile_resource.go | 10 ++--- .../provider/delay_profiles_data_source.go | 4 +- .../download_client_aria2_resource.go | 8 ++-- .../download_client_config_data_source.go | 2 +- .../download_client_config_resource.go | 6 +-- .../provider/download_client_data_source.go | 8 +++- .../download_client_deluge_resource.go | 8 ++-- .../download_client_flood_resource.go | 8 ++-- .../download_client_hadouken_resource.go | 8 ++-- .../download_client_nzbget_resource.go | 8 ++-- .../download_client_nzbvortex_resource.go | 8 ++-- .../download_client_pneumatic_resource.go | 8 ++-- .../download_client_qbittorrent_resource.go | 8 ++-- internal/provider/download_client_resource.go | 20 ++++++--- .../download_client_rtorrent_resource.go | 8 ++-- .../download_client_sabnzbd_resource.go | 8 ++-- ...nload_client_torrent_blackhole_resource.go | 8 ++-- ...lient_torrent_download_station_resource.go | 8 ++-- .../download_client_transmission_resource.go | 8 ++-- ...wnload_client_usenet_blackhole_resource.go | 8 ++-- ...client_usenet_download_station_resource.go | 8 ++-- .../download_client_utorrent_resource.go | 8 ++-- .../provider/download_client_vuze_resource.go | 8 ++-- .../provider/download_clients_data_source.go | 4 +- internal/provider/host_data_source.go | 2 +- internal/provider/host_resource.go | 6 +-- internal/provider/import_list_data_source.go | 8 +++- .../import_list_exclusion_data_source.go | 9 ++-- .../import_list_exclusion_resource.go | 8 ++-- .../import_list_exclusions_data_source.go | 4 +- ...mport_list_goodreads_bookshelf_resource.go | 8 ++-- .../import_list_goodreads_list_resource.go | 8 ++-- ...ort_list_goodreads_owned_books_resource.go | 8 ++-- .../import_list_goodreads_series_resource.go | 8 ++-- .../import_list_lazy_librarian_resource.go | 8 ++-- ...mport_list_lazy_librarian_resource_test.go | 2 +- .../provider/import_list_readarr_resource.go | 8 ++-- internal/provider/import_list_resource.go | 20 ++++++--- internal/provider/import_lists_data_source.go | 4 +- .../provider/indexer_config_data_source.go | 2 +- internal/provider/indexer_config_resource.go | 6 +-- internal/provider/indexer_data_source.go | 8 +++- .../provider/indexer_filelist_resource.go | 8 ++-- internal/provider/indexer_gazelle_resource.go | 8 ++-- .../provider/indexer_iptorrents_resource.go | 8 ++-- internal/provider/indexer_newznab_resource.go | 8 ++-- internal/provider/indexer_nyaa_resource.go | 8 ++-- internal/provider/indexer_resource.go | 20 ++++++--- .../provider/indexer_torrent_rss_resource.go | 8 ++-- .../provider/indexer_torrentleech_resource.go | 8 ++-- internal/provider/indexer_torznab_resource.go | 8 ++-- internal/provider/indexers_data_source.go | 4 +- .../provider/media_management_data_source.go | 2 +- .../provider/media_management_resource.go | 6 +-- .../provider/metadata_config_data_source.go | 2 +- internal/provider/metadata_config_resource.go | 6 +-- .../provider/metadata_profile_data_source.go | 8 +++- .../provider/metadata_profile_resource.go | 8 ++-- .../provider/metadata_profiles_data_source.go | 4 +- internal/provider/naming_data_source.go | 2 +- internal/provider/naming_resource.go | 8 ++-- .../provider/notification_boxcar_resource.go | 8 ++-- .../notification_custom_script_resource.go | 8 ++-- internal/provider/notification_data_source.go | 8 +++- .../provider/notification_discord_resource.go | 8 ++-- .../provider/notification_email_resource.go | 8 ++-- ...fication_goodreads_bookshelves_resource.go | 8 ++-- ...fication_goodreads_owned_books_resource.go | 8 ++-- .../provider/notification_gotify_resource.go | 8 ++-- .../provider/notification_join_resource.go | 8 ++-- .../provider/notification_kavita_resource.go | 8 ++-- .../provider/notification_mailgun_resource.go | 8 ++-- .../notification_notifiarr_resource.go | 8 ++-- .../provider/notification_ntfy_resource.go | 8 ++-- .../provider/notification_prowl_resource.go | 8 ++-- .../notification_pushbullet_resource.go | 8 ++-- .../notification_pushover_resource.go | 8 ++-- internal/provider/notification_resource.go | 20 ++++++--- .../notification_sendgrid_resource.go | 8 ++-- .../provider/notification_slack_resource.go | 8 ++-- .../notification_subsonic_resource.go | 8 ++-- .../notification_synology_indexer_resource.go | 8 ++-- .../notification_telegram_resource.go | 8 ++-- .../provider/notification_twitter_resource.go | 8 ++-- .../provider/notification_webhook_resource.go | 8 ++-- .../provider/notifications_data_source.go | 4 +- internal/provider/provider.go | 2 +- internal/provider/provider_test.go | 2 +- internal/provider/quality_data_source.go | 8 +++- .../quality_definition_data_source.go | 8 +++- .../provider/quality_definition_resource.go | 8 ++-- .../quality_definitions_data_source.go | 4 +- .../provider/quality_profile_data_source.go | 8 +++- internal/provider/quality_profile_resource.go | 44 ++++++++++++------- .../provider/quality_profiles_data_source.go | 4 +- .../provider/release_profile_data_source.go | 8 +++- internal/provider/release_profile_resource.go | 8 ++-- .../provider/release_profiles_data_source.go | 4 +- .../remote_path_mapping_data_source.go | 8 +++- .../provider/remote_path_mapping_resource.go | 8 ++-- .../remote_path_mappings_data_source.go | 4 +- internal/provider/root_folder_data_source.go | 8 +++- .../provider/root_folder_data_source_test.go | 5 ++- internal/provider/root_folder_resource.go | 8 ++-- internal/provider/root_folders_data_source.go | 4 +- .../provider/system_status_data_source.go | 2 +- internal/provider/tag_data_source.go | 8 +++- internal/provider/tag_resource.go | 8 ++-- internal/provider/tags_data_source.go | 4 +- 117 files changed, 526 insertions(+), 398 deletions(-) diff --git a/internal/provider/author_data_source.go b/internal/provider/author_data_source.go index 77e3a90..2631075 100644 --- a/internal/provider/author_data_source.go +++ b/internal/provider/author_data_source.go @@ -97,14 +97,18 @@ func (d *AuthorDataSource) Read(ctx context.Context, req datasource.ReadRequest, } // Get authors current value - response, _, err := d.client.AuthorApi.ListAuthor(ctx).Execute() + response, _, err := d.client.AuthorAPI.ListAuthor(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, authorDataSourceName, err)) return } - data.find(ctx, data.ForeignAuthorID.ValueString(), response, &resp.Diagnostics) + pointerResponse := make([]*readarr.AuthorResource, len(response)) + for i := range response { + pointerResponse[i] = &response[i] + } + data.find(ctx, data.ForeignAuthorID.ValueString(), pointerResponse, &resp.Diagnostics) tflog.Trace(ctx, "read "+authorDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/author_resource.go b/internal/provider/author_resource.go index 3579f1c..0cef4ea 100644 --- a/internal/provider/author_resource.go +++ b/internal/provider/author_resource.go @@ -156,7 +156,7 @@ func (r *AuthorResource) Create(ctx context.Context, req resource.CreateRequest, options.SetMonitor(readarr.MONITORTYPES_ALL) options.SetSearchForMissingBooks(true) - response, _, err := r.client.AuthorApi.CreateAuthor(ctx).AuthorResource(*request).Execute() + response, _, err := r.client.AuthorAPI.CreateAuthor(ctx).AuthorResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, authorResourceName, err)) @@ -180,7 +180,7 @@ func (r *AuthorResource) Read(ctx context.Context, req resource.ReadRequest, res } // Get author current value - response, _, err := r.client.AuthorApi.GetAuthorById(ctx, int32(author.ID.ValueInt64())).Execute() + response, _, err := r.client.AuthorAPI.GetAuthorById(ctx, int32(author.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, authorResourceName, err)) @@ -206,7 +206,7 @@ func (r *AuthorResource) Update(ctx context.Context, req resource.UpdateRequest, // Update Author request := author.read(ctx, &resp.Diagnostics) - response, _, err := r.client.AuthorApi.UpdateAuthor(ctx, fmt.Sprint(request.GetId())).AuthorResource(*request).Execute() + response, _, err := r.client.AuthorAPI.UpdateAuthor(ctx, fmt.Sprint(request.GetId())).AuthorResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, authorResourceName, err)) @@ -229,7 +229,7 @@ func (r *AuthorResource) Delete(ctx context.Context, req resource.DeleteRequest, } // Delete author current value - _, err := r.client.AuthorApi.DeleteAuthor(ctx, int32(ID)).Execute() + _, err := r.client.AuthorAPI.DeleteAuthor(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, authorResourceName, err)) diff --git a/internal/provider/authors_data_source.go b/internal/provider/authors_data_source.go index 56b8823..867f4e6 100644 --- a/internal/provider/authors_data_source.go +++ b/internal/provider/authors_data_source.go @@ -107,17 +107,21 @@ func (d *AuthorsDataSource) Configure(ctx context.Context, req datasource.Config func (d *AuthorsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get authors current value - response, _, err := d.client.AuthorApi.ListAuthor(ctx).Execute() + response, _, err := d.client.AuthorAPI.ListAuthor(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.List, authorsDataSourceName, err)) - return } tflog.Trace(ctx, "read "+authorsDataSourceName) - // Map response body to resource schema attribute - authors := make([]Author, len(response)) - for i, m := range response { + + pointerResponse := make([]*readarr.AuthorResource, len(response)) + for i := range response { + pointerResponse[i] = &response[i] + } + + authors := make([]Author, len(pointerResponse)) + for i, m := range pointerResponse { authors[i].write(ctx, m, &resp.Diagnostics) } diff --git a/internal/provider/custom_format_condition_data_source.go b/internal/provider/custom_format_condition_data_source.go index 1ccf1cb..51e6e5b 100644 --- a/internal/provider/custom_format_condition_data_source.go +++ b/internal/provider/custom_format_condition_data_source.go @@ -150,7 +150,11 @@ func (c *CustomFormatCondition) write(ctx context.Context, spec *readarr.CustomF c.Name = types.StringValue(spec.GetName()) c.Negate = types.BoolValue(spec.GetNegate()) c.Required = types.BoolValue(spec.GetRequired()) - helpers.WriteFields(ctx, c, spec.GetFields(), customFormatFields) + pointerFields := make([]*readarr.Field, len(spec.GetFields())) + for i := range spec.GetFields() { + pointerFields[i] = &spec.GetFields()[i] + } + helpers.WriteFields(ctx, c, pointerFields, customFormatFields) } func (c *CustomFormatCondition) read(ctx context.Context) *readarr.CustomFormatSpecificationSchema { @@ -160,7 +164,13 @@ func (c *CustomFormatCondition) read(ctx context.Context) *readarr.CustomFormatS spec.SetImplementation(c.Implementation.ValueString()) spec.SetNegate(c.Negate.ValueBool()) spec.SetRequired(c.Required.ValueBool()) - spec.SetFields(helpers.ReadFields(ctx, c, customFormatFields)) + + pointerFields := helpers.ReadFields(ctx, c, customFormatFields) + var fields []readarr.Field + for _, f := range pointerFields { + fields = append(fields, *f) + } + spec.SetFields(fields) return spec } diff --git a/internal/provider/custom_format_data_source.go b/internal/provider/custom_format_data_source.go index 96335d2..84a9fc8 100644 --- a/internal/provider/custom_format_data_source.go +++ b/internal/provider/custom_format_data_source.go @@ -102,14 +102,18 @@ func (d *CustomFormatDataSource) Read(ctx context.Context, req datasource.ReadRe return } // Get customFormat current value - response, _, err := d.client.CustomFormatApi.ListCustomFormat(ctx).Execute() + response, _, err := d.client.CustomFormatAPI.ListCustomFormat(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, customFormatDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + pointerResponse := make([]*readarr.CustomFormatResource, len(response)) + for i := range response { + pointerResponse[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), pointerResponse, &resp.Diagnostics) tflog.Trace(ctx, "read "+customFormatDataSourceName) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } diff --git a/internal/provider/custom_format_resource.go b/internal/provider/custom_format_resource.go index a84492e..72d241b 100644 --- a/internal/provider/custom_format_resource.go +++ b/internal/provider/custom_format_resource.go @@ -149,7 +149,7 @@ func (r *CustomFormatResource) Create(ctx context.Context, req resource.CreateRe // Create new CustomFormat request := format.read(ctx, &resp.Diagnostics) - response, _, err := r.client.CustomFormatApi.CreateCustomFormat(ctx).CustomFormatResource(*request).Execute() + response, _, err := r.client.CustomFormatAPI.CreateCustomFormat(ctx).CustomFormatResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, customFormatResourceName, err)) @@ -176,7 +176,7 @@ func (r *CustomFormatResource) Read(ctx context.Context, req resource.ReadReques } // Get CustomFormat current value - response, _, err := r.client.CustomFormatApi.GetCustomFormatById(ctx, int32(format.ID.ValueInt64())).Execute() + response, _, err := r.client.CustomFormatAPI.GetCustomFormatById(ctx, int32(format.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, customFormatResourceName, err)) @@ -205,7 +205,7 @@ func (r *CustomFormatResource) Update(ctx context.Context, req resource.UpdateRe // Update CustomFormat request := format.read(ctx, &resp.Diagnostics) - response, _, err := r.client.CustomFormatApi.UpdateCustomFormat(ctx, strconv.Itoa(int(request.GetId()))).CustomFormatResource(*request).Execute() + response, _, err := r.client.CustomFormatAPI.UpdateCustomFormat(ctx, strconv.Itoa(int(request.GetId()))).CustomFormatResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, customFormatResourceName, err)) @@ -231,7 +231,7 @@ func (r *CustomFormatResource) Delete(ctx context.Context, req resource.DeleteRe } // Delete CustomFormat current value - _, err := r.client.CustomFormatApi.DeleteCustomFormat(ctx, int32(ID)).Execute() + _, err := r.client.CustomFormatAPI.DeleteCustomFormat(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, customFormatResourceName, err)) @@ -252,7 +252,8 @@ func (c *CustomFormat) write(ctx context.Context, customFormat *readarr.CustomFo specs := make([]CustomFormatCondition, len(customFormat.Specifications)) for n, s := range customFormat.Specifications { - specs[n].write(ctx, s) + specs[n] = CustomFormatCondition{} + specs[n].write(ctx, &s) } c.ID = types.Int64Value(int64(customFormat.GetId())) @@ -265,10 +266,10 @@ func (c *CustomFormat) write(ctx context.Context, customFormat *readarr.CustomFo func (c *CustomFormat) read(ctx context.Context, diags *diag.Diagnostics) *readarr.CustomFormatResource { specifications := make([]CustomFormatCondition, len(c.Specifications.Elements())) diags.Append(c.Specifications.ElementsAs(ctx, &specifications, false)...) - specs := make([]*readarr.CustomFormatSpecificationSchema, len(specifications)) + specs := make([]readarr.CustomFormatSpecificationSchema, len(specifications)) for n, s := range specifications { - specs[n] = s.read(ctx) + specs[n] = *s.read(ctx) } format := readarr.NewCustomFormatResource() diff --git a/internal/provider/custom_formats_data_source.go b/internal/provider/custom_formats_data_source.go index 990c506..14fca44 100644 --- a/internal/provider/custom_formats_data_source.go +++ b/internal/provider/custom_formats_data_source.go @@ -113,8 +113,8 @@ func (d *CustomFormatsDataSource) Configure(ctx context.Context, req datasource. } func (d *CustomFormatsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { - // Get custom formatss current value - response, _, err := d.client.CustomFormatApi.ListCustomFormat(ctx).Execute() + // Get custom formats current value + response, _, err := d.client.CustomFormatAPI.ListCustomFormat(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.List, customFormatsDataSourceName, err)) @@ -122,9 +122,14 @@ func (d *CustomFormatsDataSource) Read(ctx context.Context, _ datasource.ReadReq } tflog.Trace(ctx, "read "+customFormatsDataSourceName) - // Map response body to resource schema attribute - formats := make([]CustomFormat, len(response)) - for i, p := range response { + + pointerResponse := make([]*readarr.CustomFormatResource, len(response)) + for i := range response { + pointerResponse[i] = &response[i] + } + + formats := make([]CustomFormat, len(pointerResponse)) + for i, p := range pointerResponse { formats[i].write(ctx, p, &resp.Diagnostics) } diff --git a/internal/provider/delay_profile_data_source.go b/internal/provider/delay_profile_data_source.go index 0cde8b3..494b696 100644 --- a/internal/provider/delay_profile_data_source.go +++ b/internal/provider/delay_profile_data_source.go @@ -88,14 +88,18 @@ func (d *DelayProfileDataSource) Read(ctx context.Context, req datasource.ReadRe return } // Get delayprofiles current value - response, _, err := d.client.DelayProfileApi.ListDelayProfile(ctx).Execute() + response, _, err := d.client.DelayProfileAPI.ListDelayProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, delayProfileDataSourceName, err)) return } - data.find(ctx, data.ID.ValueInt64(), response, &resp.Diagnostics) + profiles := make([]*readarr.DelayProfileResource, len(response)) + for i := range response { + profiles[i] = &response[i] + } + data.find(ctx, data.ID.ValueInt64(), profiles, &resp.Diagnostics) tflog.Trace(ctx, "read "+delayProfileDataSourceName) // Map response body to resource schema attribute diff --git a/internal/provider/delay_profile_resource.go b/internal/provider/delay_profile_resource.go index c805b24..a9a96fd 100644 --- a/internal/provider/delay_profile_resource.go +++ b/internal/provider/delay_profile_resource.go @@ -139,7 +139,7 @@ func (r *DelayProfileResource) Create(ctx context.Context, req resource.CreateRe request := profile.read(ctx, &resp.Diagnostics) // Create new DelayProfile - response, _, err := r.client.DelayProfileApi.CreateDelayProfile(ctx).DelayProfileResource(*request).Execute() + response, _, err := r.client.DelayProfileAPI.CreateDelayProfile(ctx).DelayProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, delayProfileResourceName, err)) @@ -152,7 +152,7 @@ func (r *DelayProfileResource) Create(ctx context.Context, req resource.CreateRe if !profile.Order.IsUnknown() { response.Order = request.Order - response, _, err = r.client.DelayProfileApi.UpdateDelayProfile(ctx, strconv.Itoa(int(response.GetId()))).DelayProfileResource(*response).Execute() + response, _, err = r.client.DelayProfileAPI.UpdateDelayProfile(ctx, strconv.Itoa(int(response.GetId()))).DelayProfileResource(*response).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, delayProfileResourceName, err)) @@ -176,7 +176,7 @@ func (r *DelayProfileResource) Read(ctx context.Context, req resource.ReadReques } // Get delayprofile current value - response, _, err := r.client.DelayProfileApi.GetDelayProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() + response, _, err := r.client.DelayProfileAPI.GetDelayProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, delayProfileResourceName, err)) @@ -203,7 +203,7 @@ func (r *DelayProfileResource) Update(ctx context.Context, req resource.UpdateRe request := profile.read(ctx, &resp.Diagnostics) // Update DelayProfile - response, _, err := r.client.DelayProfileApi.UpdateDelayProfile(ctx, strconv.Itoa(int(request.GetId()))).DelayProfileResource(*request).Execute() + response, _, err := r.client.DelayProfileAPI.UpdateDelayProfile(ctx, strconv.Itoa(int(request.GetId()))).DelayProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, delayProfileResourceName, err)) @@ -226,7 +226,7 @@ func (r *DelayProfileResource) Delete(ctx context.Context, req resource.DeleteRe } // Delete delayprofile current value - _, err := r.client.DelayProfileApi.DeleteDelayProfile(ctx, int32(ID)).Execute() + _, err := r.client.DelayProfileAPI.DeleteDelayProfile(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, delayProfileResourceName, err)) diff --git a/internal/provider/delay_profiles_data_source.go b/internal/provider/delay_profiles_data_source.go index b27208f..3a40861 100644 --- a/internal/provider/delay_profiles_data_source.go +++ b/internal/provider/delay_profiles_data_source.go @@ -98,7 +98,7 @@ func (d *DelayProfilesDataSource) Configure(ctx context.Context, req datasource. func (d *DelayProfilesDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get delayprofiles current value - response, _, err := d.client.DelayProfileApi.ListDelayProfile(ctx).Execute() + response, _, err := d.client.DelayProfileAPI.ListDelayProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.List, delayProfileResourceName, err)) @@ -109,7 +109,7 @@ func (d *DelayProfilesDataSource) Read(ctx context.Context, _ datasource.ReadReq // Map response body to resource schema attribute profiles := make([]DelayProfile, len(response)) for i, p := range response { - profiles[i].write(ctx, p, &resp.Diagnostics) + profiles[i].write(ctx, &p, &resp.Diagnostics) } profileList, diags := types.SetValueFrom(ctx, DelayProfile{}.getType(), profiles) diff --git a/internal/provider/download_client_aria2_resource.go b/internal/provider/download_client_aria2_resource.go index d80486c..3542015 100644 --- a/internal/provider/download_client_aria2_resource.go +++ b/internal/provider/download_client_aria2_resource.go @@ -183,7 +183,7 @@ func (r *DownloadClientAria2Resource) Create(ctx context.Context, req resource.C // Create new DownloadClientAria2 request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientAria2ResourceName, err)) @@ -207,7 +207,7 @@ func (r *DownloadClientAria2Resource) Read(ctx context.Context, req resource.Rea } // Get DownloadClientAria2 current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientAria2ResourceName, err)) @@ -233,7 +233,7 @@ func (r *DownloadClientAria2Resource) Update(ctx context.Context, req resource.U // Update DownloadClientAria2 request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientAria2ResourceName, err)) @@ -256,7 +256,7 @@ func (r *DownloadClientAria2Resource) Delete(ctx context.Context, req resource.D } // Delete DownloadClientAria2 current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientAria2ResourceName, err)) diff --git a/internal/provider/download_client_config_data_source.go b/internal/provider/download_client_config_data_source.go index 1374999..f1063f7 100644 --- a/internal/provider/download_client_config_data_source.go +++ b/internal/provider/download_client_config_data_source.go @@ -61,7 +61,7 @@ func (d *DownloadClientConfigDataSource) Configure(ctx context.Context, req data func (d *DownloadClientConfigDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get indexer config current value - response, _, err := d.client.DownloadClientConfigApi.GetDownloadClientConfig(ctx).Execute() + response, _, err := d.client.DownloadClientConfigAPI.GetDownloadClientConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientConfigDataSourceName, err)) diff --git a/internal/provider/download_client_config_resource.go b/internal/provider/download_client_config_resource.go index eee3b5d..afee244 100644 --- a/internal/provider/download_client_config_resource.go +++ b/internal/provider/download_client_config_resource.go @@ -92,7 +92,7 @@ func (r *DownloadClientConfigResource) Create(ctx context.Context, req resource. request.SetId(1) // Create new DownloadClientConfig - response, _, err := r.client.DownloadClientConfigApi.UpdateDownloadClientConfig(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientConfigResource(*request).Execute() + response, _, err := r.client.DownloadClientConfigAPI.UpdateDownloadClientConfig(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientConfigResourceName, err)) @@ -116,7 +116,7 @@ func (r *DownloadClientConfigResource) Read(ctx context.Context, req resource.Re } // Get downloadClientConfig current value - response, _, err := r.client.DownloadClientConfigApi.GetDownloadClientConfig(ctx).Execute() + response, _, err := r.client.DownloadClientConfigAPI.GetDownloadClientConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientConfigResourceName, err)) @@ -143,7 +143,7 @@ func (r *DownloadClientConfigResource) Update(ctx context.Context, req resource. request := config.read() // Update DownloadClientConfig - response, _, err := r.client.DownloadClientConfigApi.UpdateDownloadClientConfig(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientConfigResource(*request).Execute() + response, _, err := r.client.DownloadClientConfigAPI.UpdateDownloadClientConfig(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientConfigResourceName, err)) diff --git a/internal/provider/download_client_data_source.go b/internal/provider/download_client_data_source.go index 551d7e6..90d4f3d 100644 --- a/internal/provider/download_client_data_source.go +++ b/internal/provider/download_client_data_source.go @@ -236,14 +236,18 @@ func (d *DownloadClientDataSource) Read(ctx context.Context, req datasource.Read return } // Get downloadClient current value - response, _, err := d.client.DownloadClientApi.ListDownloadClient(ctx).Execute() + response, _, err := d.client.DownloadClientAPI.ListDownloadClient(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + clients := make([]*readarr.DownloadClientResource, len(response)) + for i := range response { + clients[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), clients, &resp.Diagnostics) tflog.Trace(ctx, "read "+downloadClientDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/download_client_deluge_resource.go b/internal/provider/download_client_deluge_resource.go index ee80b61..d4d28e2 100644 --- a/internal/provider/download_client_deluge_resource.go +++ b/internal/provider/download_client_deluge_resource.go @@ -232,7 +232,7 @@ func (r *DownloadClientDelugeResource) Create(ctx context.Context, req resource. // Create new DownloadClientDeluge request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientDelugeResourceName, err)) @@ -256,7 +256,7 @@ func (r *DownloadClientDelugeResource) Read(ctx context.Context, req resource.Re } // Get DownloadClientDeluge current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientDelugeResourceName, err)) @@ -282,7 +282,7 @@ func (r *DownloadClientDelugeResource) Update(ctx context.Context, req resource. // Update DownloadClientDeluge request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientDelugeResourceName, err)) @@ -305,7 +305,7 @@ func (r *DownloadClientDelugeResource) Delete(ctx context.Context, req resource. } // Delete DownloadClientDeluge current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientDelugeResourceName, err)) diff --git a/internal/provider/download_client_flood_resource.go b/internal/provider/download_client_flood_resource.go index 0ffbde2..7550b55 100644 --- a/internal/provider/download_client_flood_resource.go +++ b/internal/provider/download_client_flood_resource.go @@ -235,7 +235,7 @@ func (r *DownloadClientFloodResource) Create(ctx context.Context, req resource.C // Create new DownloadClientFlood request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientFloodResourceName, err)) @@ -259,7 +259,7 @@ func (r *DownloadClientFloodResource) Read(ctx context.Context, req resource.Rea } // Get DownloadClientFlood current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientFloodResourceName, err)) @@ -285,7 +285,7 @@ func (r *DownloadClientFloodResource) Update(ctx context.Context, req resource.U // Update DownloadClientFlood request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientFloodResourceName, err)) @@ -308,7 +308,7 @@ func (r *DownloadClientFloodResource) Delete(ctx context.Context, req resource.D } // Delete DownloadClientFlood current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientFloodResourceName, err)) diff --git a/internal/provider/download_client_hadouken_resource.go b/internal/provider/download_client_hadouken_resource.go index 1f608a4..e5b4056 100644 --- a/internal/provider/download_client_hadouken_resource.go +++ b/internal/provider/download_client_hadouken_resource.go @@ -198,7 +198,7 @@ func (r *DownloadClientHadoukenResource) Create(ctx context.Context, req resourc // Create new DownloadClientHadouken request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientHadoukenResourceName, err)) @@ -222,7 +222,7 @@ func (r *DownloadClientHadoukenResource) Read(ctx context.Context, req resource. } // Get DownloadClientHadouken current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientHadoukenResourceName, err)) @@ -248,7 +248,7 @@ func (r *DownloadClientHadoukenResource) Update(ctx context.Context, req resourc // Update DownloadClientHadouken request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientHadoukenResourceName, err)) @@ -271,7 +271,7 @@ func (r *DownloadClientHadoukenResource) Delete(ctx context.Context, req resourc } // Delete DownloadClientHadouken current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientHadoukenResourceName, err)) diff --git a/internal/provider/download_client_nzbget_resource.go b/internal/provider/download_client_nzbget_resource.go index 2155b50..3d94bbb 100644 --- a/internal/provider/download_client_nzbget_resource.go +++ b/internal/provider/download_client_nzbget_resource.go @@ -232,7 +232,7 @@ func (r *DownloadClientNzbgetResource) Create(ctx context.Context, req resource. // Create new DownloadClientNzbget request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientNzbgetResourceName, err)) @@ -256,7 +256,7 @@ func (r *DownloadClientNzbgetResource) Read(ctx context.Context, req resource.Re } // Get DownloadClientNzbget current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientNzbgetResourceName, err)) @@ -282,7 +282,7 @@ func (r *DownloadClientNzbgetResource) Update(ctx context.Context, req resource. // Update DownloadClientNzbget request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientNzbgetResourceName, err)) @@ -305,7 +305,7 @@ func (r *DownloadClientNzbgetResource) Delete(ctx context.Context, req resource. } // Delete DownloadClientNzbget current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientNzbgetResourceName, err)) diff --git a/internal/provider/download_client_nzbvortex_resource.go b/internal/provider/download_client_nzbvortex_resource.go index d578b1c..1e64c26 100644 --- a/internal/provider/download_client_nzbvortex_resource.go +++ b/internal/provider/download_client_nzbvortex_resource.go @@ -206,7 +206,7 @@ func (r *DownloadClientNzbvortexResource) Create(ctx context.Context, req resour // Create new DownloadClientNzbvortex request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientNzbvortexResourceName, err)) @@ -230,7 +230,7 @@ func (r *DownloadClientNzbvortexResource) Read(ctx context.Context, req resource } // Get DownloadClientNzbvortex current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientNzbvortexResourceName, err)) @@ -256,7 +256,7 @@ func (r *DownloadClientNzbvortexResource) Update(ctx context.Context, req resour // Update DownloadClientNzbvortex request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientNzbvortexResourceName, err)) @@ -279,7 +279,7 @@ func (r *DownloadClientNzbvortexResource) Delete(ctx context.Context, req resour } // Delete DownloadClientNzbvortex current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientNzbvortexResourceName, err)) diff --git a/internal/provider/download_client_pneumatic_resource.go b/internal/provider/download_client_pneumatic_resource.go index 55dddb0..ec00f68 100644 --- a/internal/provider/download_client_pneumatic_resource.go +++ b/internal/provider/download_client_pneumatic_resource.go @@ -157,7 +157,7 @@ func (r *DownloadClientPneumaticResource) Create(ctx context.Context, req resour // Create new DownloadClientPneumatic request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientPneumaticResourceName, err)) @@ -181,7 +181,7 @@ func (r *DownloadClientPneumaticResource) Read(ctx context.Context, req resource } // Get DownloadClientPneumatic current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientPneumaticResourceName, err)) @@ -207,7 +207,7 @@ func (r *DownloadClientPneumaticResource) Update(ctx context.Context, req resour // Update DownloadClientPneumatic request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientPneumaticResourceName, err)) @@ -230,7 +230,7 @@ func (r *DownloadClientPneumaticResource) Delete(ctx context.Context, req resour } // Delete DownloadClientPneumatic current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientPneumaticResourceName, err)) diff --git a/internal/provider/download_client_qbittorrent_resource.go b/internal/provider/download_client_qbittorrent_resource.go index 6928f16..f60d53f 100644 --- a/internal/provider/download_client_qbittorrent_resource.go +++ b/internal/provider/download_client_qbittorrent_resource.go @@ -261,7 +261,7 @@ func (r *DownloadClientQbittorrentResource) Create(ctx context.Context, req reso // Create new DownloadClientQbittorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientQbittorrentResourceName, err)) @@ -285,7 +285,7 @@ func (r *DownloadClientQbittorrentResource) Read(ctx context.Context, req resour } // Get DownloadClientQbittorrent current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientQbittorrentResourceName, err)) @@ -311,7 +311,7 @@ func (r *DownloadClientQbittorrentResource) Update(ctx context.Context, req reso // Update DownloadClientQbittorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientQbittorrentResourceName, err)) @@ -334,7 +334,7 @@ func (r *DownloadClientQbittorrentResource) Delete(ctx context.Context, req reso } // Delete DownloadClientQbittorrent current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientQbittorrentResourceName, err)) diff --git a/internal/provider/download_client_resource.go b/internal/provider/download_client_resource.go index 50c1e6a..19beca7 100644 --- a/internal/provider/download_client_resource.go +++ b/internal/provider/download_client_resource.go @@ -412,7 +412,7 @@ func (r *DownloadClientResource) Create(ctx context.Context, req resource.Create // Create new DownloadClient request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientResourceName, err)) @@ -439,7 +439,7 @@ func (r *DownloadClientResource) Read(ctx context.Context, req resource.ReadRequ } // Get DownloadClient current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientResourceName, err)) @@ -468,7 +468,7 @@ func (r *DownloadClientResource) Update(ctx context.Context, req resource.Update // Update DownloadClient request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientResourceName, err)) @@ -494,7 +494,7 @@ func (r *DownloadClientResource) Delete(ctx context.Context, req resource.Delete } // Delete DownloadClient current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientResourceName, err)) @@ -528,7 +528,11 @@ func (d *DownloadClient) write(ctx context.Context, downloadClient *readarr.Down d.AdditionalTags = types.SetValueMust(types.Int64Type, nil) d.FieldTags = types.SetValueMust(types.StringType, nil) d.PostImportTags = types.SetValueMust(types.StringType, nil) - helpers.WriteFields(ctx, d, downloadClient.GetFields(), downloadClientFields) + fields := make([]*readarr.Field, len(downloadClient.GetFields())) + for i := range downloadClient.GetFields() { + fields[i] = &downloadClient.GetFields()[i] + } + helpers.WriteFields(ctx, d, fields, downloadClientFields) } func (d *DownloadClient) read(ctx context.Context, diags *diag.Diagnostics) *readarr.DownloadClientResource { @@ -543,7 +547,11 @@ func (d *DownloadClient) read(ctx context.Context, diags *diag.Diagnostics) *rea client.SetName(d.Name.ValueString()) client.SetProtocol(readarr.DownloadProtocol(d.Protocol.ValueString())) diags.Append(d.Tags.ElementsAs(ctx, &client.Tags, true)...) - client.SetFields(helpers.ReadFields(ctx, d, downloadClientFields)) + fields := make([]readarr.Field, len(helpers.ReadFields(ctx, d, downloadClientFields))) + for i, f := range helpers.ReadFields(ctx, d, downloadClientFields) { + fields[i] = *f + } + client.SetFields(fields) return client } diff --git a/internal/provider/download_client_rtorrent_resource.go b/internal/provider/download_client_rtorrent_resource.go index 53fc3ab..9c59ae3 100644 --- a/internal/provider/download_client_rtorrent_resource.go +++ b/internal/provider/download_client_rtorrent_resource.go @@ -248,7 +248,7 @@ func (r *DownloadClientRtorrentResource) Create(ctx context.Context, req resourc // Create new DownloadClientRtorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientRtorrentResourceName, err)) @@ -272,7 +272,7 @@ func (r *DownloadClientRtorrentResource) Read(ctx context.Context, req resource. } // Get DownloadClientRtorrent current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientRtorrentResourceName, err)) @@ -298,7 +298,7 @@ func (r *DownloadClientRtorrentResource) Update(ctx context.Context, req resourc // Update DownloadClientRtorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientRtorrentResourceName, err)) @@ -321,7 +321,7 @@ func (r *DownloadClientRtorrentResource) Delete(ctx context.Context, req resourc } // Delete DownloadClientRtorrent current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientRtorrentResourceName, err)) diff --git a/internal/provider/download_client_sabnzbd_resource.go b/internal/provider/download_client_sabnzbd_resource.go index 95d3bdf..2f8bd92 100644 --- a/internal/provider/download_client_sabnzbd_resource.go +++ b/internal/provider/download_client_sabnzbd_resource.go @@ -233,7 +233,7 @@ func (r *DownloadClientSabnzbdResource) Create(ctx context.Context, req resource // Create new DownloadClientSabnzbd request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientSabnzbdResourceName, err)) @@ -257,7 +257,7 @@ func (r *DownloadClientSabnzbdResource) Read(ctx context.Context, req resource.R } // Get DownloadClientSabnzbd current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientSabnzbdResourceName, err)) @@ -283,7 +283,7 @@ func (r *DownloadClientSabnzbdResource) Update(ctx context.Context, req resource // Update DownloadClientSabnzbd request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientSabnzbdResourceName, err)) @@ -306,7 +306,7 @@ func (r *DownloadClientSabnzbdResource) Delete(ctx context.Context, req resource } // Delete DownloadClientSabnzbd current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientSabnzbdResourceName, err)) diff --git a/internal/provider/download_client_torrent_blackhole_resource.go b/internal/provider/download_client_torrent_blackhole_resource.go index 68ad8ac..4b972d7 100644 --- a/internal/provider/download_client_torrent_blackhole_resource.go +++ b/internal/provider/download_client_torrent_blackhole_resource.go @@ -181,7 +181,7 @@ func (r *DownloadClientTorrentBlackholeResource) Create(ctx context.Context, req // Create new DownloadClientTorrentBlackhole request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientTorrentBlackholeResourceName, err)) @@ -205,7 +205,7 @@ func (r *DownloadClientTorrentBlackholeResource) Read(ctx context.Context, req r } // Get DownloadClientTorrentBlackhole current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientTorrentBlackholeResourceName, err)) @@ -231,7 +231,7 @@ func (r *DownloadClientTorrentBlackholeResource) Update(ctx context.Context, req // Update DownloadClientTorrentBlackhole request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientTorrentBlackholeResourceName, err)) @@ -254,7 +254,7 @@ func (r *DownloadClientTorrentBlackholeResource) Delete(ctx context.Context, req } // Delete DownloadClientTorrentBlackhole current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientTorrentBlackholeResourceName, err)) diff --git a/internal/provider/download_client_torrent_download_station_resource.go b/internal/provider/download_client_torrent_download_station_resource.go index 4291c90..9d5aa35 100644 --- a/internal/provider/download_client_torrent_download_station_resource.go +++ b/internal/provider/download_client_torrent_download_station_resource.go @@ -200,7 +200,7 @@ func (r *DownloadClientTorrentDownloadStationResource) Create(ctx context.Contex // Create new DownloadClientTorrentDownloadStation request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientTorrentDownloadStationResourceName, err)) @@ -224,7 +224,7 @@ func (r *DownloadClientTorrentDownloadStationResource) Read(ctx context.Context, } // Get DownloadClientTorrentDownloadStation current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientTorrentDownloadStationResourceName, err)) @@ -250,7 +250,7 @@ func (r *DownloadClientTorrentDownloadStationResource) Update(ctx context.Contex // Update DownloadClientTorrentDownloadStation request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientTorrentDownloadStationResourceName, err)) @@ -273,7 +273,7 @@ func (r *DownloadClientTorrentDownloadStationResource) Delete(ctx context.Contex } // Delete DownloadClientTorrentDownloadStation current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientTorrentDownloadStationResourceName, err)) diff --git a/internal/provider/download_client_transmission_resource.go b/internal/provider/download_client_transmission_resource.go index 55da1a0..8003ba3 100644 --- a/internal/provider/download_client_transmission_resource.go +++ b/internal/provider/download_client_transmission_resource.go @@ -240,7 +240,7 @@ func (r *DownloadClientTransmissionResource) Create(ctx context.Context, req res // Create new DownloadClientTransmission request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientTransmissionResourceName, err)) @@ -264,7 +264,7 @@ func (r *DownloadClientTransmissionResource) Read(ctx context.Context, req resou } // Get DownloadClientTransmission current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientTransmissionResourceName, err)) @@ -290,7 +290,7 @@ func (r *DownloadClientTransmissionResource) Update(ctx context.Context, req res // Update DownloadClientTransmission request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientTransmissionResourceName, err)) @@ -313,7 +313,7 @@ func (r *DownloadClientTransmissionResource) Delete(ctx context.Context, req res } // Delete DownloadClientTransmission current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientTransmissionResourceName, err)) diff --git a/internal/provider/download_client_usenet_blackhole_resource.go b/internal/provider/download_client_usenet_blackhole_resource.go index cd1c4b2..baa4de3 100644 --- a/internal/provider/download_client_usenet_blackhole_resource.go +++ b/internal/provider/download_client_usenet_blackhole_resource.go @@ -157,7 +157,7 @@ func (r *DownloadClientUsenetBlackholeResource) Create(ctx context.Context, req // Create new DownloadClientUsenetBlackhole request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientUsenetBlackholeResourceName, err)) @@ -181,7 +181,7 @@ func (r *DownloadClientUsenetBlackholeResource) Read(ctx context.Context, req re } // Get DownloadClientUsenetBlackhole current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientUsenetBlackholeResourceName, err)) @@ -207,7 +207,7 @@ func (r *DownloadClientUsenetBlackholeResource) Update(ctx context.Context, req // Update DownloadClientUsenetBlackhole request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientUsenetBlackholeResourceName, err)) @@ -230,7 +230,7 @@ func (r *DownloadClientUsenetBlackholeResource) Delete(ctx context.Context, req } // Delete DownloadClientUsenetBlackhole current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientUsenetBlackholeResourceName, err)) diff --git a/internal/provider/download_client_usenet_download_station_resource.go b/internal/provider/download_client_usenet_download_station_resource.go index b6b8f13..2013beb 100644 --- a/internal/provider/download_client_usenet_download_station_resource.go +++ b/internal/provider/download_client_usenet_download_station_resource.go @@ -200,7 +200,7 @@ func (r *DownloadClientUsenetDownloadStationResource) Create(ctx context.Context // Create new DownloadClientUsenetDownloadStation request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientUsenetDownloadStationResourceName, err)) @@ -224,7 +224,7 @@ func (r *DownloadClientUsenetDownloadStationResource) Read(ctx context.Context, } // Get DownloadClientUsenetDownloadStation current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientUsenetDownloadStationResourceName, err)) @@ -250,7 +250,7 @@ func (r *DownloadClientUsenetDownloadStationResource) Update(ctx context.Context // Update DownloadClientUsenetDownloadStation request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientUsenetDownloadStationResourceName, err)) @@ -273,7 +273,7 @@ func (r *DownloadClientUsenetDownloadStationResource) Delete(ctx context.Context } // Delete DownloadClientUsenetDownloadStation current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientUsenetDownloadStationResourceName, err)) diff --git a/internal/provider/download_client_utorrent_resource.go b/internal/provider/download_client_utorrent_resource.go index 9761cb5..a2db72e 100644 --- a/internal/provider/download_client_utorrent_resource.go +++ b/internal/provider/download_client_utorrent_resource.go @@ -243,7 +243,7 @@ func (r *DownloadClientUtorrentResource) Create(ctx context.Context, req resourc // Create new DownloadClientUtorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientUtorrentResourceName, err)) @@ -267,7 +267,7 @@ func (r *DownloadClientUtorrentResource) Read(ctx context.Context, req resource. } // Get DownloadClientUtorrent current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientUtorrentResourceName, err)) @@ -293,7 +293,7 @@ func (r *DownloadClientUtorrentResource) Update(ctx context.Context, req resourc // Update DownloadClientUtorrent request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientUtorrentResourceName, err)) @@ -316,7 +316,7 @@ func (r *DownloadClientUtorrentResource) Delete(ctx context.Context, req resourc } // Delete DownloadClientUtorrent current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientUtorrentResourceName, err)) diff --git a/internal/provider/download_client_vuze_resource.go b/internal/provider/download_client_vuze_resource.go index cae0040..51c5e18 100644 --- a/internal/provider/download_client_vuze_resource.go +++ b/internal/provider/download_client_vuze_resource.go @@ -240,7 +240,7 @@ func (r *DownloadClientVuzeResource) Create(ctx context.Context, req resource.Cr // Create new DownloadClientVuze request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.CreateDownloadClient(ctx).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, downloadClientVuzeResourceName, err)) @@ -264,7 +264,7 @@ func (r *DownloadClientVuzeResource) Read(ctx context.Context, req resource.Read } // Get DownloadClientVuze current value - response, _, err := r.client.DownloadClientApi.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() + response, _, err := r.client.DownloadClientAPI.GetDownloadClientById(ctx, int32(client.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientVuzeResourceName, err)) @@ -290,7 +290,7 @@ func (r *DownloadClientVuzeResource) Update(ctx context.Context, req resource.Up // Update DownloadClientVuze request := client.read(ctx, &resp.Diagnostics) - response, _, err := r.client.DownloadClientApi.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() + response, _, err := r.client.DownloadClientAPI.UpdateDownloadClient(ctx, strconv.Itoa(int(request.GetId()))).DownloadClientResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, downloadClientVuzeResourceName, err)) @@ -313,7 +313,7 @@ func (r *DownloadClientVuzeResource) Delete(ctx context.Context, req resource.De } // Delete DownloadClientVuze current value - _, err := r.client.DownloadClientApi.DeleteDownloadClient(ctx, int32(ID)).Execute() + _, err := r.client.DownloadClientAPI.DeleteDownloadClient(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, downloadClientVuzeResourceName, err)) diff --git a/internal/provider/download_clients_data_source.go b/internal/provider/download_clients_data_source.go index 99ada83..d5cdcab 100644 --- a/internal/provider/download_clients_data_source.go +++ b/internal/provider/download_clients_data_source.go @@ -247,7 +247,7 @@ func (d *DownloadClientsDataSource) Configure(ctx context.Context, req datasourc func (d *DownloadClientsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get download clients current value - response, _, err := d.client.DownloadClientApi.ListDownloadClient(ctx).Execute() + response, _, err := d.client.DownloadClientAPI.ListDownloadClient(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, downloadClientsDataSourceName, err)) @@ -258,7 +258,7 @@ func (d *DownloadClientsDataSource) Read(ctx context.Context, _ datasource.ReadR // Map response body to resource schema attribute clients := make([]DownloadClient, len(response)) for i, d := range response { - clients[i].write(ctx, d, &resp.Diagnostics) + clients[i].write(ctx, &d, &resp.Diagnostics) } clientList, diags := types.SetValueFrom(ctx, DownloadClient{}.getType(), clients) diff --git a/internal/provider/host_data_source.go b/internal/provider/host_data_source.go index 5c7ab6d..a48495e 100644 --- a/internal/provider/host_data_source.go +++ b/internal/provider/host_data_source.go @@ -233,7 +233,7 @@ func (d *HostDataSource) Read(ctx context.Context, _ datasource.ReadRequest, res resp.Diagnostics.Append(tempDiag...) // Get host current value - response, _, err := d.client.HostConfigApi.GetHostConfig(ctx).Execute() + response, _, err := d.client.HostConfigAPI.GetHostConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, hostDataSourceName, err)) diff --git a/internal/provider/host_resource.go b/internal/provider/host_resource.go index ff3c7a8..b71ca46 100644 --- a/internal/provider/host_resource.go +++ b/internal/provider/host_resource.go @@ -403,7 +403,7 @@ func (r *HostResource) Create(ctx context.Context, req resource.CreateRequest, r request.SetId(1) // Create new Host - response, _, err := r.client.HostConfigApi.UpdateHostConfig(ctx, strconv.Itoa(int(request.GetId()))).HostConfigResource(*request).Execute() + response, _, err := r.client.HostConfigAPI.UpdateHostConfig(ctx, strconv.Itoa(int(request.GetId()))).HostConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, hostResourceName, err)) @@ -427,7 +427,7 @@ func (r *HostResource) Read(ctx context.Context, req resource.ReadRequest, resp } // Get host current value - response, _, err := r.client.HostConfigApi.GetHostConfig(ctx).Execute() + response, _, err := r.client.HostConfigAPI.GetHostConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, hostResourceName, err)) @@ -454,7 +454,7 @@ func (r *HostResource) Update(ctx context.Context, req resource.UpdateRequest, r request := host.read(ctx, &resp.Diagnostics) // Update Host - response, _, err := r.client.HostConfigApi.UpdateHostConfig(ctx, strconv.Itoa(int(request.GetId()))).HostConfigResource(*request).Execute() + response, _, err := r.client.HostConfigAPI.UpdateHostConfig(ctx, strconv.Itoa(int(request.GetId()))).HostConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, hostResourceName, err)) diff --git a/internal/provider/import_list_data_source.go b/internal/provider/import_list_data_source.go index c4a0a84..f7a5d34 100644 --- a/internal/provider/import_list_data_source.go +++ b/internal/provider/import_list_data_source.go @@ -171,14 +171,18 @@ func (d *ImportListDataSource) Read(ctx context.Context, req datasource.ReadRequ return } // Get importList current value - response, _, err := d.client.ImportListApi.ListImportList(ctx).Execute() + response, _, err := d.client.ImportListAPI.ListImportList(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + lists := make([]*readarr.ImportListResource, len(response)) + for i := range response { + lists[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), lists, &resp.Diagnostics) tflog.Trace(ctx, "read "+importListDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/import_list_exclusion_data_source.go b/internal/provider/import_list_exclusion_data_source.go index c31bf8b..ab78fa0 100644 --- a/internal/provider/import_list_exclusion_data_source.go +++ b/internal/provider/import_list_exclusion_data_source.go @@ -65,14 +65,17 @@ func (d *ImportListExclusionDataSource) Read(ctx context.Context, req datasource } // Get importListExclusions current value - response, _, err := d.client.ImportListExclusionApi.ListImportListExclusion(ctx).Execute() + response, _, err := d.client.ImportListExclusionAPI.ListImportListExclusion(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListExclusionDataSourceName, err)) return } - - data.find(data.ForeignID.ValueString(), response, &resp.Diagnostics) + exclusionLists := make([]*readarr.ImportListExclusionResource, len(response)) + for i := range response { + exclusionLists[i] = &response[i] + } + data.find(data.ForeignID.ValueString(), exclusionLists, &resp.Diagnostics) tflog.Trace(ctx, "read "+importListExclusionDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/import_list_exclusion_resource.go b/internal/provider/import_list_exclusion_resource.go index b3e1968..18a8235 100644 --- a/internal/provider/import_list_exclusion_resource.go +++ b/internal/provider/import_list_exclusion_resource.go @@ -95,7 +95,7 @@ func (r *ImportListExclusionResource) Create(ctx context.Context, req resource.C // Create new ImportListExclusion request := importListExclusion.read() - response, _, err := r.client.ImportListExclusionApi.CreateImportListExclusion(ctx).ImportListExclusionResource(*request).Execute() + response, _, err := r.client.ImportListExclusionAPI.CreateImportListExclusion(ctx).ImportListExclusionResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListExclusionResourceName, err)) @@ -119,7 +119,7 @@ func (r *ImportListExclusionResource) Read(ctx context.Context, req resource.Rea } // Get importListExclusion current value - response, _, err := r.client.ImportListExclusionApi.GetImportListExclusionById(ctx, int32(importListExclusion.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListExclusionAPI.GetImportListExclusionById(ctx, int32(importListExclusion.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListExclusionResourceName, err)) @@ -145,7 +145,7 @@ func (r *ImportListExclusionResource) Update(ctx context.Context, req resource.U // Update ImportListExclusion request := importListExclusion.read() - response, _, err := r.client.ImportListExclusionApi.UpdateImportListExclusion(ctx, strconv.Itoa(int(request.GetId()))).ImportListExclusionResource(*request).Execute() + response, _, err := r.client.ImportListExclusionAPI.UpdateImportListExclusion(ctx, strconv.Itoa(int(request.GetId()))).ImportListExclusionResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListExclusionResourceName, err)) @@ -168,7 +168,7 @@ func (r *ImportListExclusionResource) Delete(ctx context.Context, req resource.D } // Delete importListExclusion current value - _, err := r.client.ImportListExclusionApi.DeleteImportListExclusion(ctx, int32(ID)).Execute() + _, err := r.client.ImportListExclusionAPI.DeleteImportListExclusion(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListExclusionResourceName, err)) diff --git a/internal/provider/import_list_exclusions_data_source.go b/internal/provider/import_list_exclusions_data_source.go index 5815ee9..6fae124 100644 --- a/internal/provider/import_list_exclusions_data_source.go +++ b/internal/provider/import_list_exclusions_data_source.go @@ -76,7 +76,7 @@ func (d *ImportListExclusionsDataSource) Configure(ctx context.Context, req data func (d *ImportListExclusionsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get importListExclusions current value - response, _, err := d.client.ImportListExclusionApi.ListImportListExclusion(ctx).Execute() + response, _, err := d.client.ImportListExclusionAPI.ListImportListExclusion(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListExclusionsDataSourceName, err)) @@ -87,7 +87,7 @@ func (d *ImportListExclusionsDataSource) Read(ctx context.Context, _ datasource. // Map response body to resource schema attribute importListExclusions := make([]ImportListExclusion, len(response)) for i, t := range response { - importListExclusions[i].write(t) + importListExclusions[i].write(&t) } exclusionList, diags := types.SetValueFrom(ctx, ImportListExclusion{}.getType(), importListExclusions) diff --git a/internal/provider/import_list_goodreads_bookshelf_resource.go b/internal/provider/import_list_goodreads_bookshelf_resource.go index debddfe..d780a7c 100644 --- a/internal/provider/import_list_goodreads_bookshelf_resource.go +++ b/internal/provider/import_list_goodreads_bookshelf_resource.go @@ -240,7 +240,7 @@ func (r *ImportListGoodreadsBookshelfResource) Create(ctx context.Context, req r // Create new ImportListGoodreadsBookshelf request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListGoodreadsBookshelfResourceName, err)) @@ -264,7 +264,7 @@ func (r *ImportListGoodreadsBookshelfResource) Read(ctx context.Context, req res } // Get ImportListGoodreadsBookshelf current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListGoodreadsBookshelfResourceName, err)) @@ -290,7 +290,7 @@ func (r *ImportListGoodreadsBookshelfResource) Update(ctx context.Context, req r // Update ImportListGoodreadsBookshelf request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListGoodreadsBookshelfResourceName, err)) @@ -313,7 +313,7 @@ func (r *ImportListGoodreadsBookshelfResource) Delete(ctx context.Context, req r } // Delete ImportListGoodreadsBookshelf current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListGoodreadsBookshelfResourceName, err)) diff --git a/internal/provider/import_list_goodreads_list_resource.go b/internal/provider/import_list_goodreads_list_resource.go index 055c0ce..abb1a25 100644 --- a/internal/provider/import_list_goodreads_list_resource.go +++ b/internal/provider/import_list_goodreads_list_resource.go @@ -198,7 +198,7 @@ func (r *ImportListGoodreadsListResource) Create(ctx context.Context, req resour // Create new ImportListGoodreadsList request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListGoodreadsListResourceName, err)) @@ -222,7 +222,7 @@ func (r *ImportListGoodreadsListResource) Read(ctx context.Context, req resource } // Get ImportListGoodreadsList current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListGoodreadsListResourceName, err)) @@ -248,7 +248,7 @@ func (r *ImportListGoodreadsListResource) Update(ctx context.Context, req resour // Update ImportListGoodreadsList request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListGoodreadsListResourceName, err)) @@ -271,7 +271,7 @@ func (r *ImportListGoodreadsListResource) Delete(ctx context.Context, req resour } // Delete ImportListGoodreadsList current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListGoodreadsListResourceName, err)) diff --git a/internal/provider/import_list_goodreads_owned_books_resource.go b/internal/provider/import_list_goodreads_owned_books_resource.go index 78d944f..502725a 100644 --- a/internal/provider/import_list_goodreads_owned_books_resource.go +++ b/internal/provider/import_list_goodreads_owned_books_resource.go @@ -231,7 +231,7 @@ func (r *ImportListGoodreadsOwnedBooksResource) Create(ctx context.Context, req // Create new ImportListGoodreadsOwnedBooks request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListGoodreadsOwnedBooksResourceName, err)) @@ -255,7 +255,7 @@ func (r *ImportListGoodreadsOwnedBooksResource) Read(ctx context.Context, req re } // Get ImportListGoodreadsOwnedBooks current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListGoodreadsOwnedBooksResourceName, err)) @@ -281,7 +281,7 @@ func (r *ImportListGoodreadsOwnedBooksResource) Update(ctx context.Context, req // Update ImportListGoodreadsOwnedBooks request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListGoodreadsOwnedBooksResourceName, err)) @@ -304,7 +304,7 @@ func (r *ImportListGoodreadsOwnedBooksResource) Delete(ctx context.Context, req } // Delete ImportListGoodreadsOwnedBooks current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListGoodreadsOwnedBooksResourceName, err)) diff --git a/internal/provider/import_list_goodreads_series_resource.go b/internal/provider/import_list_goodreads_series_resource.go index 52db42b..25e6421 100644 --- a/internal/provider/import_list_goodreads_series_resource.go +++ b/internal/provider/import_list_goodreads_series_resource.go @@ -198,7 +198,7 @@ func (r *ImportListGoodreadsSeriesResource) Create(ctx context.Context, req reso // Create new ImportListGoodreadsSeries request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListGoodreadsSeriesResourceName, err)) @@ -222,7 +222,7 @@ func (r *ImportListGoodreadsSeriesResource) Read(ctx context.Context, req resour } // Get ImportListGoodreadsSeries current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListGoodreadsSeriesResourceName, err)) @@ -248,7 +248,7 @@ func (r *ImportListGoodreadsSeriesResource) Update(ctx context.Context, req reso // Update ImportListGoodreadsSeries request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListGoodreadsSeriesResourceName, err)) @@ -271,7 +271,7 @@ func (r *ImportListGoodreadsSeriesResource) Delete(ctx context.Context, req reso } // Delete ImportListGoodreadsSeries current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListGoodreadsSeriesResourceName, err)) diff --git a/internal/provider/import_list_lazy_librarian_resource.go b/internal/provider/import_list_lazy_librarian_resource.go index 02e3aa2..883c19a 100644 --- a/internal/provider/import_list_lazy_librarian_resource.go +++ b/internal/provider/import_list_lazy_librarian_resource.go @@ -206,7 +206,7 @@ func (r *ImportListLazyLibrarianResource) Create(ctx context.Context, req resour // Create new ImportListLazyLibrarian request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListLazyLibrarianResourceName, err)) @@ -230,7 +230,7 @@ func (r *ImportListLazyLibrarianResource) Read(ctx context.Context, req resource } // Get ImportListLazyLibrarian current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListLazyLibrarianResourceName, err)) @@ -256,7 +256,7 @@ func (r *ImportListLazyLibrarianResource) Update(ctx context.Context, req resour // Update ImportListLazyLibrarian request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListLazyLibrarianResourceName, err)) @@ -279,7 +279,7 @@ func (r *ImportListLazyLibrarianResource) Delete(ctx context.Context, req resour } // Delete ImportListLazyLibrarian current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListLazyLibrarianResourceName, err)) diff --git a/internal/provider/import_list_lazy_librarian_resource_test.go b/internal/provider/import_list_lazy_librarian_resource_test.go index ebb1893..7d5693b 100644 --- a/internal/provider/import_list_lazy_librarian_resource_test.go +++ b/internal/provider/import_list_lazy_librarian_resource_test.go @@ -64,6 +64,6 @@ func testAccImportListLazyLibrarianResourceConfig(name, folder string) string { metadata_profile_id = 1 name = "%s" base_url = "http://localhost:5299" - api_key = "ApiKey" + api_key = "APIKey" }`, folder, name) } diff --git a/internal/provider/import_list_readarr_resource.go b/internal/provider/import_list_readarr_resource.go index 097e4fb..87f1f6d 100644 --- a/internal/provider/import_list_readarr_resource.go +++ b/internal/provider/import_list_readarr_resource.go @@ -224,7 +224,7 @@ func (r *ImportListReadarrResource) Create(ctx context.Context, req resource.Cre // Create new ImportListReadarr request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListReadarrResourceName, err)) @@ -248,7 +248,7 @@ func (r *ImportListReadarrResource) Read(ctx context.Context, req resource.ReadR } // Get ImportListReadarr current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListReadarrResourceName, err)) @@ -274,7 +274,7 @@ func (r *ImportListReadarrResource) Update(ctx context.Context, req resource.Upd // Update ImportListReadarr request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListReadarrResourceName, err)) @@ -297,7 +297,7 @@ func (r *ImportListReadarrResource) Delete(ctx context.Context, req resource.Del } // Delete ImportListReadarr current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListReadarrResourceName, err)) diff --git a/internal/provider/import_list_resource.go b/internal/provider/import_list_resource.go index e79cbd4..d81c4b7 100644 --- a/internal/provider/import_list_resource.go +++ b/internal/provider/import_list_resource.go @@ -290,7 +290,7 @@ func (r *ImportListResource) Create(ctx context.Context, req resource.CreateRequ // Create new ImportList request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.CreateImportList(ctx).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.CreateImportList(ctx).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, importListResourceName, err)) @@ -317,7 +317,7 @@ func (r *ImportListResource) Read(ctx context.Context, req resource.ReadRequest, } // Get ImportList current value - response, _, err := r.client.ImportListApi.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() + response, _, err := r.client.ImportListAPI.GetImportListById(ctx, int32(importList.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListResourceName, err)) @@ -346,7 +346,7 @@ func (r *ImportListResource) Update(ctx context.Context, req resource.UpdateRequ // Update ImportList request := importList.read(ctx, &resp.Diagnostics) - response, _, err := r.client.ImportListApi.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() + response, _, err := r.client.ImportListAPI.UpdateImportList(ctx, strconv.Itoa(int(request.GetId()))).ImportListResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, importListResourceName, err)) @@ -372,7 +372,7 @@ func (r *ImportListResource) Delete(ctx context.Context, req resource.DeleteRequ } // Delete ImportList current value - _, err := r.client.ImportListApi.DeleteImportList(ctx, int32(ID)).Execute() + _, err := r.client.ImportListAPI.DeleteImportList(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, importListResourceName, err)) @@ -411,7 +411,11 @@ func (i *ImportList) write(ctx context.Context, importList *readarr.ImportListRe i.ProfileIds = types.SetValueMust(types.Int64Type, nil) i.TagIds = types.SetValueMust(types.Int64Type, nil) i.BookshelfIds = types.SetValueMust(types.StringType, nil) - helpers.WriteFields(ctx, i, importList.GetFields(), importListFields) + fields := make([]*readarr.Field, len(importList.GetFields())) + for i := range importList.GetFields() { + fields[i] = &importList.GetFields()[i] + } + helpers.WriteFields(ctx, i, fields, importListFields) } func (i *ImportList) read(ctx context.Context, diags *diag.Diagnostics) *readarr.ImportListResource { @@ -431,7 +435,11 @@ func (i *ImportList) read(ctx context.Context, diags *diag.Diagnostics) *readarr list.SetImplementation(i.Implementation.ValueString()) list.SetName(i.Name.ValueString()) diags.Append(i.Tags.ElementsAs(ctx, &list.Tags, true)...) - list.SetFields(helpers.ReadFields(ctx, i, importListFields)) + fields := make([]readarr.Field, len(helpers.ReadFields(ctx, i, importListFields))) + for i, f := range helpers.ReadFields(ctx, i, importListFields) { + fields[i] = *f + } + list.SetFields(fields) return list } diff --git a/internal/provider/import_lists_data_source.go b/internal/provider/import_lists_data_source.go index be9d44c..8f79096 100644 --- a/internal/provider/import_lists_data_source.go +++ b/internal/provider/import_lists_data_source.go @@ -182,7 +182,7 @@ func (d *ImportListsDataSource) Configure(ctx context.Context, req datasource.Co func (d *ImportListsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get import lists current value - response, _, err := d.client.ImportListApi.ListImportList(ctx).Execute() + response, _, err := d.client.ImportListAPI.ListImportList(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, importListsDataSourceName, err)) @@ -193,7 +193,7 @@ func (d *ImportListsDataSource) Read(ctx context.Context, _ datasource.ReadReque // Map response body to resource schema attribute importLists := make([]ImportList, len(response)) for i, d := range response { - importLists[i].write(ctx, d, &resp.Diagnostics) + importLists[i].write(ctx, &d, &resp.Diagnostics) } listList, diags := types.SetValueFrom(ctx, ImportList{}.getType(), importLists) diff --git a/internal/provider/indexer_config_data_source.go b/internal/provider/indexer_config_data_source.go index a3ac9b0..2a014f7 100644 --- a/internal/provider/indexer_config_data_source.go +++ b/internal/provider/indexer_config_data_source.go @@ -65,7 +65,7 @@ func (d *IndexerConfigDataSource) Configure(ctx context.Context, req datasource. func (d *IndexerConfigDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get indexer config current value - response, _, err := d.client.IndexerConfigApi.GetIndexerConfig(ctx).Execute() + response, _, err := d.client.IndexerConfigAPI.GetIndexerConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerConfigDataSourceName, err)) diff --git a/internal/provider/indexer_config_resource.go b/internal/provider/indexer_config_resource.go index 73edbfa..1339295 100644 --- a/internal/provider/indexer_config_resource.go +++ b/internal/provider/indexer_config_resource.go @@ -97,7 +97,7 @@ func (r *IndexerConfigResource) Create(ctx context.Context, req resource.CreateR request.SetId(1) // Create new IndexerConfig - response, _, err := r.client.IndexerConfigApi.UpdateIndexerConfig(ctx, strconv.Itoa(int(request.GetId()))).IndexerConfigResource(*request).Execute() + response, _, err := r.client.IndexerConfigAPI.UpdateIndexerConfig(ctx, strconv.Itoa(int(request.GetId()))).IndexerConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerConfigResourceName, err)) @@ -121,7 +121,7 @@ func (r *IndexerConfigResource) Read(ctx context.Context, req resource.ReadReque } // Get indexerConfig current value - response, _, err := r.client.IndexerConfigApi.GetIndexerConfig(ctx).Execute() + response, _, err := r.client.IndexerConfigAPI.GetIndexerConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerConfigResourceName, err)) @@ -148,7 +148,7 @@ func (r *IndexerConfigResource) Update(ctx context.Context, req resource.UpdateR request := config.read() // Update IndexerConfig - response, _, err := r.client.IndexerConfigApi.UpdateIndexerConfig(ctx, strconv.Itoa(int(request.GetId()))).IndexerConfigResource(*request).Execute() + response, _, err := r.client.IndexerConfigAPI.UpdateIndexerConfig(ctx, strconv.Itoa(int(request.GetId()))).IndexerConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerConfigResourceName, err)) diff --git a/internal/provider/indexer_data_source.go b/internal/provider/indexer_data_source.go index 255c88f..fb0d3d0 100644 --- a/internal/provider/indexer_data_source.go +++ b/internal/provider/indexer_data_source.go @@ -175,14 +175,18 @@ func (d *IndexerDataSource) Read(ctx context.Context, req datasource.ReadRequest return } // Get indexer current value - response, _, err := d.client.IndexerApi.ListIndexer(ctx).Execute() + response, _, err := d.client.IndexerAPI.ListIndexer(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + indexers := make([]*readarr.IndexerResource, len(response)) + for i := range response { + indexers[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), indexers, &resp.Diagnostics) tflog.Trace(ctx, "read "+indexerDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/indexer_filelist_resource.go b/internal/provider/indexer_filelist_resource.go index 283a81d..8537602 100644 --- a/internal/provider/indexer_filelist_resource.go +++ b/internal/provider/indexer_filelist_resource.go @@ -215,7 +215,7 @@ func (r *IndexerFilelistResource) Create(ctx context.Context, req resource.Creat // Create new IndexerFilelist request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerFilelistResourceName, err)) @@ -239,7 +239,7 @@ func (r *IndexerFilelistResource) Read(ctx context.Context, req resource.ReadReq } // Get IndexerFilelist current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerFilelistResourceName, err)) @@ -265,7 +265,7 @@ func (r *IndexerFilelistResource) Update(ctx context.Context, req resource.Updat // Update IndexerFilelist request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerFilelistResourceName, err)) @@ -288,7 +288,7 @@ func (r *IndexerFilelistResource) Delete(ctx context.Context, req resource.Delet } // Delete IndexerFilelist current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerFilelistResourceName, err)) diff --git a/internal/provider/indexer_gazelle_resource.go b/internal/provider/indexer_gazelle_resource.go index 11fe61d..38ab261 100644 --- a/internal/provider/indexer_gazelle_resource.go +++ b/internal/provider/indexer_gazelle_resource.go @@ -206,7 +206,7 @@ func (r *IndexerGazelleResource) Create(ctx context.Context, req resource.Create // Create new IndexerGazelle request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerGazelleResourceName, err)) @@ -230,7 +230,7 @@ func (r *IndexerGazelleResource) Read(ctx context.Context, req resource.ReadRequ } // Get IndexerGazelle current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerGazelleResourceName, err)) @@ -256,7 +256,7 @@ func (r *IndexerGazelleResource) Update(ctx context.Context, req resource.Update // Update IndexerGazelle request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerGazelleResourceName, err)) @@ -279,7 +279,7 @@ func (r *IndexerGazelleResource) Delete(ctx context.Context, req resource.Delete } // Delete IndexerGazelle current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerGazelleResourceName, err)) diff --git a/internal/provider/indexer_iptorrents_resource.go b/internal/provider/indexer_iptorrents_resource.go index 931a3b9..a453ca8 100644 --- a/internal/provider/indexer_iptorrents_resource.go +++ b/internal/provider/indexer_iptorrents_resource.go @@ -174,7 +174,7 @@ func (r *IndexerIptorrentsResource) Create(ctx context.Context, req resource.Cre // Create new IndexerIptorrents request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerIptorrentsResourceName, err)) @@ -198,7 +198,7 @@ func (r *IndexerIptorrentsResource) Read(ctx context.Context, req resource.ReadR } // Get IndexerIptorrents current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerIptorrentsResourceName, err)) @@ -224,7 +224,7 @@ func (r *IndexerIptorrentsResource) Update(ctx context.Context, req resource.Upd // Update IndexerIptorrents request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerIptorrentsResourceName, err)) @@ -247,7 +247,7 @@ func (r *IndexerIptorrentsResource) Delete(ctx context.Context, req resource.Del } // Delete IndexerIptorrents current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerIptorrentsResourceName, err)) diff --git a/internal/provider/indexer_newznab_resource.go b/internal/provider/indexer_newznab_resource.go index 3a60a83..d981799 100644 --- a/internal/provider/indexer_newznab_resource.go +++ b/internal/provider/indexer_newznab_resource.go @@ -192,7 +192,7 @@ func (r *IndexerNewznabResource) Create(ctx context.Context, req resource.Create // Create new IndexerNewznab request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerNewznabResourceName, err)) @@ -216,7 +216,7 @@ func (r *IndexerNewznabResource) Read(ctx context.Context, req resource.ReadRequ } // Get IndexerNewznab current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerNewznabResourceName, err)) @@ -242,7 +242,7 @@ func (r *IndexerNewznabResource) Update(ctx context.Context, req resource.Update // Update IndexerNewznab request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerNewznabResourceName, err)) @@ -265,7 +265,7 @@ func (r *IndexerNewznabResource) Delete(ctx context.Context, req resource.Delete } // Delete IndexerNewznab current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerNewznabResourceName, err)) diff --git a/internal/provider/indexer_nyaa_resource.go b/internal/provider/indexer_nyaa_resource.go index 6c872f6..0b70b02 100644 --- a/internal/provider/indexer_nyaa_resource.go +++ b/internal/provider/indexer_nyaa_resource.go @@ -198,7 +198,7 @@ func (r *IndexerNyaaResource) Create(ctx context.Context, req resource.CreateReq // Create new IndexerNyaa request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerNyaaResourceName, err)) @@ -222,7 +222,7 @@ func (r *IndexerNyaaResource) Read(ctx context.Context, req resource.ReadRequest } // Get IndexerNyaa current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerNyaaResourceName, err)) @@ -248,7 +248,7 @@ func (r *IndexerNyaaResource) Update(ctx context.Context, req resource.UpdateReq // Update IndexerNyaa request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerNyaaResourceName, err)) @@ -271,7 +271,7 @@ func (r *IndexerNyaaResource) Delete(ctx context.Context, req resource.DeleteReq } // Delete IndexerNyaa current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerNyaaResourceName, err)) diff --git a/internal/provider/indexer_resource.go b/internal/provider/indexer_resource.go index c1c334e..b371332 100644 --- a/internal/provider/indexer_resource.go +++ b/internal/provider/indexer_resource.go @@ -296,7 +296,7 @@ func (r *IndexerResource) Create(ctx context.Context, req resource.CreateRequest // Create new Indexer request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerResourceName, err)) @@ -323,7 +323,7 @@ func (r *IndexerResource) Read(ctx context.Context, req resource.ReadRequest, re } // Get Indexer current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerResourceName, err)) @@ -352,7 +352,7 @@ func (r *IndexerResource) Update(ctx context.Context, req resource.UpdateRequest // Update Indexer request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerResourceName, err)) @@ -378,7 +378,7 @@ func (r *IndexerResource) Delete(ctx context.Context, req resource.DeleteRequest } // Delete Indexer current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerResourceName, err)) @@ -410,7 +410,11 @@ func (i *Indexer) write(ctx context.Context, indexer *readarr.IndexerResource, d i.Name = types.StringValue(indexer.GetName()) i.Protocol = types.StringValue(string(indexer.GetProtocol())) i.Categories = types.SetValueMust(types.Int64Type, nil) - helpers.WriteFields(ctx, i, indexer.GetFields(), indexerFields) + fields := make([]*readarr.Field, len(indexer.GetFields())) + for i := range indexer.GetFields() { + fields[i] = &indexer.GetFields()[i] + } + helpers.WriteFields(ctx, i, fields, indexerFields) } func (i *Indexer) read(ctx context.Context, diags *diag.Diagnostics) *readarr.IndexerResource { @@ -425,7 +429,11 @@ func (i *Indexer) read(ctx context.Context, diags *diag.Diagnostics) *readarr.In indexer.SetName(i.Name.ValueString()) indexer.SetProtocol(readarr.DownloadProtocol(i.Protocol.ValueString())) diags.Append(i.Tags.ElementsAs(ctx, &indexer.Tags, true)...) - indexer.SetFields(helpers.ReadFields(ctx, i, indexerFields)) + fields := make([]readarr.Field, len(helpers.ReadFields(ctx, i, indexerFields))) + for i, f := range helpers.ReadFields(ctx, i, indexerFields) { + fields[i] = *f + } + indexer.SetFields(fields) return indexer } diff --git a/internal/provider/indexer_torrent_rss_resource.go b/internal/provider/indexer_torrent_rss_resource.go index 680e704..4201c39 100644 --- a/internal/provider/indexer_torrent_rss_resource.go +++ b/internal/provider/indexer_torrent_rss_resource.go @@ -190,7 +190,7 @@ func (r *IndexerTorrentRssResource) Create(ctx context.Context, req resource.Cre // Create new IndexerTorrentRss request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerTorrentRssResourceName, err)) @@ -214,7 +214,7 @@ func (r *IndexerTorrentRssResource) Read(ctx context.Context, req resource.ReadR } // Get IndexerTorrentRss current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerTorrentRssResourceName, err)) @@ -240,7 +240,7 @@ func (r *IndexerTorrentRssResource) Update(ctx context.Context, req resource.Upd // Update IndexerTorrentRss request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerTorrentRssResourceName, err)) @@ -263,7 +263,7 @@ func (r *IndexerTorrentRssResource) Delete(ctx context.Context, req resource.Del } // Delete IndexerTorrentRss current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerTorrentRssResourceName, err)) diff --git a/internal/provider/indexer_torrentleech_resource.go b/internal/provider/indexer_torrentleech_resource.go index f5b39ac..b8d1f00 100644 --- a/internal/provider/indexer_torrentleech_resource.go +++ b/internal/provider/indexer_torrentleech_resource.go @@ -199,7 +199,7 @@ func (r *IndexerTorrentleechResource) Create(ctx context.Context, req resource.C // Create new IndexerTorrentleech request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerTorrentleechResourceName, err)) @@ -223,7 +223,7 @@ func (r *IndexerTorrentleechResource) Read(ctx context.Context, req resource.Rea } // Get IndexerTorrentleech current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerTorrentleechResourceName, err)) @@ -249,7 +249,7 @@ func (r *IndexerTorrentleechResource) Update(ctx context.Context, req resource.U // Update IndexerTorrentleech request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerTorrentleechResourceName, err)) @@ -272,7 +272,7 @@ func (r *IndexerTorrentleechResource) Delete(ctx context.Context, req resource.D } // Delete IndexerTorrentleech current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerTorrentleechResourceName, err)) diff --git a/internal/provider/indexer_torznab_resource.go b/internal/provider/indexer_torznab_resource.go index 3decebf..4bacf55 100644 --- a/internal/provider/indexer_torznab_resource.go +++ b/internal/provider/indexer_torznab_resource.go @@ -224,7 +224,7 @@ func (r *IndexerTorznabResource) Create(ctx context.Context, req resource.Create // Create new IndexerTorznab request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.CreateIndexer(ctx).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.CreateIndexer(ctx).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, indexerTorznabResourceName, err)) @@ -248,7 +248,7 @@ func (r *IndexerTorznabResource) Read(ctx context.Context, req resource.ReadRequ } // Get IndexerTorznab current value - response, _, err := r.client.IndexerApi.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() + response, _, err := r.client.IndexerAPI.GetIndexerById(ctx, int32(indexer.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexerTorznabResourceName, err)) @@ -274,7 +274,7 @@ func (r *IndexerTorznabResource) Update(ctx context.Context, req resource.Update // Update IndexerTorznab request := indexer.read(ctx, &resp.Diagnostics) - response, _, err := r.client.IndexerApi.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() + response, _, err := r.client.IndexerAPI.UpdateIndexer(ctx, strconv.Itoa(int(request.GetId()))).IndexerResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, indexerTorznabResourceName, err)) @@ -297,7 +297,7 @@ func (r *IndexerTorznabResource) Delete(ctx context.Context, req resource.Delete } // Delete IndexerTorznab current value - _, err := r.client.IndexerApi.DeleteIndexer(ctx, int32(ID)).Execute() + _, err := r.client.IndexerAPI.DeleteIndexer(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, indexerTorznabResourceName, err)) diff --git a/internal/provider/indexers_data_source.go b/internal/provider/indexers_data_source.go index 7c7b5a3..1af4bf3 100644 --- a/internal/provider/indexers_data_source.go +++ b/internal/provider/indexers_data_source.go @@ -186,7 +186,7 @@ func (d *IndexersDataSource) Configure(ctx context.Context, req datasource.Confi func (d *IndexersDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get indexers current value - response, _, err := d.client.IndexerApi.ListIndexer(ctx).Execute() + response, _, err := d.client.IndexerAPI.ListIndexer(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, indexersDataSourceName, err)) @@ -197,7 +197,7 @@ func (d *IndexersDataSource) Read(ctx context.Context, _ datasource.ReadRequest, // Map response body to resource schema attribute indexers := make([]Indexer, len(response)) for i, p := range response { - indexers[i].write(ctx, p, &resp.Diagnostics) + indexers[i].write(ctx, &p, &resp.Diagnostics) } indexerList, diags := types.SetValueFrom(ctx, Indexer{}.getType(), indexers) diff --git a/internal/provider/media_management_data_source.go b/internal/provider/media_management_data_source.go index 8338544..00e2dba 100644 --- a/internal/provider/media_management_data_source.go +++ b/internal/provider/media_management_data_source.go @@ -121,7 +121,7 @@ func (d *MediaManagementDataSource) Configure(ctx context.Context, req datasourc func (d *MediaManagementDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get indexer config current value - response, _, err := d.client.MediaManagementConfigApi.GetMediaManagementConfig(ctx).Execute() + response, _, err := d.client.MediaManagementConfigAPI.GetMediaManagementConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, mediaManagementDataSourceName, err)) diff --git a/internal/provider/media_management_resource.go b/internal/provider/media_management_resource.go index 47a6e08..20951e6 100644 --- a/internal/provider/media_management_resource.go +++ b/internal/provider/media_management_resource.go @@ -181,7 +181,7 @@ func (r *MediaManagementResource) Create(ctx context.Context, req resource.Creat request.SetId(1) // Create new MediaManagement - response, _, err := r.client.MediaManagementConfigApi.UpdateMediaManagementConfig(ctx, strconv.Itoa(int(request.GetId()))).MediaManagementConfigResource(*request).Execute() + response, _, err := r.client.MediaManagementConfigAPI.UpdateMediaManagementConfig(ctx, strconv.Itoa(int(request.GetId()))).MediaManagementConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, mediaManagementResourceName, err)) @@ -205,7 +205,7 @@ func (r *MediaManagementResource) Read(ctx context.Context, req resource.ReadReq } // Get mediamanagement current value - response, _, err := r.client.MediaManagementConfigApi.GetMediaManagementConfig(ctx).Execute() + response, _, err := r.client.MediaManagementConfigAPI.GetMediaManagementConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, mediaManagementResourceName, err)) @@ -232,7 +232,7 @@ func (r *MediaManagementResource) Update(ctx context.Context, req resource.Updat request := management.read() // Update MediaManagement - response, _, err := r.client.MediaManagementConfigApi.UpdateMediaManagementConfig(ctx, strconv.Itoa(int(request.GetId()))).MediaManagementConfigResource(*request).Execute() + response, _, err := r.client.MediaManagementConfigAPI.UpdateMediaManagementConfig(ctx, strconv.Itoa(int(request.GetId()))).MediaManagementConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, mediaManagementResourceName, err)) diff --git a/internal/provider/metadata_config_data_source.go b/internal/provider/metadata_config_data_source.go index df8041e..56cb4bb 100644 --- a/internal/provider/metadata_config_data_source.go +++ b/internal/provider/metadata_config_data_source.go @@ -69,7 +69,7 @@ func (d *MetadataConfigDataSource) Configure(ctx context.Context, req datasource func (d *MetadataConfigDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get metadata config current value - response, _, err := d.client.MetadataProviderConfigApi.GetMetadataProviderConfig(ctx).Execute() + response, _, err := d.client.MetadataProviderConfigAPI.GetMetadataProviderConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, metadataConfigDataSourceName, err)) diff --git a/internal/provider/metadata_config_resource.go b/internal/provider/metadata_config_resource.go index 2941ac1..574bfdf 100644 --- a/internal/provider/metadata_config_resource.go +++ b/internal/provider/metadata_config_resource.go @@ -110,7 +110,7 @@ func (r *MetadataConfigResource) Create(ctx context.Context, req resource.Create request.SetId(1) // Create new MetadataConfig - response, _, err := r.client.MetadataProviderConfigApi.UpdateMetadataProviderConfig(ctx, strconv.Itoa(int(request.GetId()))).MetadataProviderConfigResource(*request).Execute() + response, _, err := r.client.MetadataProviderConfigAPI.UpdateMetadataProviderConfig(ctx, strconv.Itoa(int(request.GetId()))).MetadataProviderConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, metadataConfigResourceName, err)) @@ -134,7 +134,7 @@ func (r *MetadataConfigResource) Read(ctx context.Context, req resource.ReadRequ } // Get metadataConfig current value - response, _, err := r.client.MetadataProviderConfigApi.GetMetadataProviderConfig(ctx).Execute() + response, _, err := r.client.MetadataProviderConfigAPI.GetMetadataProviderConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, metadataConfigResourceName, err)) @@ -161,7 +161,7 @@ func (r *MetadataConfigResource) Update(ctx context.Context, req resource.Update request := config.read() // Update MetadataConfig - response, _, err := r.client.MetadataProviderConfigApi.UpdateMetadataProviderConfig(ctx, strconv.Itoa(int(request.GetId()))).MetadataProviderConfigResource(*request).Execute() + response, _, err := r.client.MetadataProviderConfigAPI.UpdateMetadataProviderConfig(ctx, strconv.Itoa(int(request.GetId()))).MetadataProviderConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, metadataConfigResourceName, err)) diff --git a/internal/provider/metadata_profile_data_source.go b/internal/provider/metadata_profile_data_source.go index 84b77ff..1361e59 100644 --- a/internal/provider/metadata_profile_data_source.go +++ b/internal/provider/metadata_profile_data_source.go @@ -95,14 +95,18 @@ func (d *MetadataProfileDataSource) Read(ctx context.Context, req datasource.Rea return } // Get metadataprofiles current value - response, _, err := d.client.MetadataProfileApi.ListMetadataProfile(ctx).Execute() + response, _, err := d.client.MetadataProfileAPI.ListMetadataProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, metadataProfileDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + profiles := make([]*readarr.MetadataProfileResource, len(response)) + for i := range response { + profiles[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), profiles, &resp.Diagnostics) tflog.Trace(ctx, "read "+metadataProfileDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/metadata_profile_resource.go b/internal/provider/metadata_profile_resource.go index a9db349..01f58a1 100644 --- a/internal/provider/metadata_profile_resource.go +++ b/internal/provider/metadata_profile_resource.go @@ -147,7 +147,7 @@ func (r *MetadataProfileResource) Create(ctx context.Context, req resource.Creat // Create new MetadataProfile request := profile.read(ctx, &resp.Diagnostics) - response, _, err := r.client.MetadataProfileApi.CreateMetadataProfile(ctx).MetadataProfileResource(*request).Execute() + response, _, err := r.client.MetadataProfileAPI.CreateMetadataProfile(ctx).MetadataProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, metadataProfileResourceName, err)) @@ -171,7 +171,7 @@ func (r *MetadataProfileResource) Read(ctx context.Context, req resource.ReadReq } // Get metadataProfile current value - response, _, err := r.client.MetadataProfileApi.GetMetadataProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() + response, _, err := r.client.MetadataProfileAPI.GetMetadataProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, metadataProfileResourceName, err)) @@ -197,7 +197,7 @@ func (r *MetadataProfileResource) Update(ctx context.Context, req resource.Updat // Update MetadataProfile request := profile.read(ctx, &resp.Diagnostics) - response, _, err := r.client.MetadataProfileApi.UpdateMetadataProfile(ctx, strconv.Itoa(int(request.GetId()))).MetadataProfileResource(*request).Execute() + response, _, err := r.client.MetadataProfileAPI.UpdateMetadataProfile(ctx, strconv.Itoa(int(request.GetId()))).MetadataProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, metadataProfileResourceName, err)) @@ -220,7 +220,7 @@ func (r *MetadataProfileResource) Delete(ctx context.Context, req resource.Delet } // Delete metadataProfile current value - _, err := r.client.MetadataProfileApi.DeleteMetadataProfile(ctx, int32(ID)).Execute() + _, err := r.client.MetadataProfileAPI.DeleteMetadataProfile(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, metadataProfileResourceName, err)) diff --git a/internal/provider/metadata_profiles_data_source.go b/internal/provider/metadata_profiles_data_source.go index 0d1939d..efa7e54 100644 --- a/internal/provider/metadata_profiles_data_source.go +++ b/internal/provider/metadata_profiles_data_source.go @@ -106,7 +106,7 @@ func (d *MetadataProfilesDataSource) Configure(ctx context.Context, req datasour func (d *MetadataProfilesDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get metadataprofiles current value - response, _, err := d.client.MetadataProfileApi.ListMetadataProfile(ctx).Execute() + response, _, err := d.client.MetadataProfileAPI.ListMetadataProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.List, metadataProfileResourceName, err)) @@ -117,7 +117,7 @@ func (d *MetadataProfilesDataSource) Read(ctx context.Context, _ datasource.Read // Map response body to resource schema attribute profiles := make([]MetadataProfile, len(response)) for i, p := range response { - profiles[i].write(ctx, p, &resp.Diagnostics) + profiles[i].write(ctx, &p, &resp.Diagnostics) } profileList, diags := types.SetValueFrom(ctx, MetadataProfile{}.getType(), profiles) diff --git a/internal/provider/naming_data_source.go b/internal/provider/naming_data_source.go index 7901c0d..bad495d 100644 --- a/internal/provider/naming_data_source.go +++ b/internal/provider/naming_data_source.go @@ -69,7 +69,7 @@ func (d *NamingDataSource) Configure(ctx context.Context, req datasource.Configu func (d *NamingDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get naming current value - response, _, err := d.client.NamingConfigApi.GetNamingConfig(ctx).Execute() + response, _, err := d.client.NamingConfigAPI.GetNamingConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, namingDataSourceName, err)) diff --git a/internal/provider/naming_resource.go b/internal/provider/naming_resource.go index dedda4b..f46a8d0 100644 --- a/internal/provider/naming_resource.go +++ b/internal/provider/naming_resource.go @@ -103,7 +103,7 @@ func (r *NamingResource) Create(ctx context.Context, req resource.CreateRequest, } // Init call if we remove this it the very first update on a brand new instance will fail - if _, _, err := r.client.NamingConfigApi.GetNamingConfig(ctx).Execute(); err != nil { + if _, _, err := r.client.NamingConfigAPI.GetNamingConfig(ctx).Execute(); err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError("init", namingResourceName, err)) return @@ -114,7 +114,7 @@ func (r *NamingResource) Create(ctx context.Context, req resource.CreateRequest, request.SetId(1) // Create new Naming - response, _, err := r.client.NamingConfigApi.UpdateNamingConfig(ctx, strconv.Itoa(int(request.GetId()))).NamingConfigResource(*request).Execute() + response, _, err := r.client.NamingConfigAPI.UpdateNamingConfig(ctx, strconv.Itoa(int(request.GetId()))).NamingConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, namingResourceName, err)) @@ -138,7 +138,7 @@ func (r *NamingResource) Read(ctx context.Context, req resource.ReadRequest, res } // Get naming current value - response, _, err := r.client.NamingConfigApi.GetNamingConfig(ctx).Execute() + response, _, err := r.client.NamingConfigAPI.GetNamingConfig(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, namingResourceName, err)) @@ -165,7 +165,7 @@ func (r *NamingResource) Update(ctx context.Context, req resource.UpdateRequest, request := naming.read() // Update Naming - response, _, err := r.client.NamingConfigApi.UpdateNamingConfig(ctx, strconv.Itoa(int(request.GetId()))).NamingConfigResource(*request).Execute() + response, _, err := r.client.NamingConfigAPI.UpdateNamingConfig(ctx, strconv.Itoa(int(request.GetId()))).NamingConfigResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, namingResourceName, err)) diff --git a/internal/provider/notification_boxcar_resource.go b/internal/provider/notification_boxcar_resource.go index 63644ba..f2c38d7 100644 --- a/internal/provider/notification_boxcar_resource.go +++ b/internal/provider/notification_boxcar_resource.go @@ -213,7 +213,7 @@ func (r *NotificationBoxcarResource) Create(ctx context.Context, req resource.Cr // Create new NotificationBoxcar request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationBoxcarResourceName, err)) @@ -237,7 +237,7 @@ func (r *NotificationBoxcarResource) Read(ctx context.Context, req resource.Read } // Get NotificationBoxcar current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationBoxcarResourceName, err)) @@ -263,7 +263,7 @@ func (r *NotificationBoxcarResource) Update(ctx context.Context, req resource.Up // Update NotificationBoxcar request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationBoxcarResourceName, err)) @@ -286,7 +286,7 @@ func (r *NotificationBoxcarResource) Delete(ctx context.Context, req resource.De } // Delete NotificationBoxcar current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationBoxcarResourceName, err)) diff --git a/internal/provider/notification_custom_script_resource.go b/internal/provider/notification_custom_script_resource.go index 8c9e712..f4dee11 100644 --- a/internal/provider/notification_custom_script_resource.go +++ b/internal/provider/notification_custom_script_resource.go @@ -220,7 +220,7 @@ func (r *NotificationCustomScriptResource) Create(ctx context.Context, req resou // Create new NotificationCustomScript request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationCustomScriptResourceName, err)) @@ -244,7 +244,7 @@ func (r *NotificationCustomScriptResource) Read(ctx context.Context, req resourc } // Get NotificationCustomScript current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationCustomScriptResourceName, err)) @@ -270,7 +270,7 @@ func (r *NotificationCustomScriptResource) Update(ctx context.Context, req resou // Update NotificationCustomScript request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationCustomScriptResourceName, err)) @@ -293,7 +293,7 @@ func (r *NotificationCustomScriptResource) Delete(ctx context.Context, req resou } // Delete NotificationCustomScript current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationCustomScriptResourceName, err)) diff --git a/internal/provider/notification_data_source.go b/internal/provider/notification_data_source.go index 4f11c42..9307052 100644 --- a/internal/provider/notification_data_source.go +++ b/internal/provider/notification_data_source.go @@ -425,14 +425,18 @@ func (d *NotificationDataSource) Read(ctx context.Context, req datasource.ReadRe return } // Get notification current value - response, _, err := d.client.NotificationApi.ListNotification(ctx).Execute() + response, _, err := d.client.NotificationAPI.ListNotification(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + notifications := make([]*readarr.NotificationResource, len(response)) + for i := range response { + notifications[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), notifications, &resp.Diagnostics) tflog.Trace(ctx, "read "+notificationDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/notification_discord_resource.go b/internal/provider/notification_discord_resource.go index 20eab7d..ea52695 100644 --- a/internal/provider/notification_discord_resource.go +++ b/internal/provider/notification_discord_resource.go @@ -244,7 +244,7 @@ func (r *NotificationDiscordResource) Create(ctx context.Context, req resource.C // Create new NotificationDiscord request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationDiscordResourceName, err)) @@ -268,7 +268,7 @@ func (r *NotificationDiscordResource) Read(ctx context.Context, req resource.Rea } // Get NotificationDiscord current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationDiscordResourceName, err)) @@ -294,7 +294,7 @@ func (r *NotificationDiscordResource) Update(ctx context.Context, req resource.U // Update NotificationDiscord request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationDiscordResourceName, err)) @@ -317,7 +317,7 @@ func (r *NotificationDiscordResource) Delete(ctx context.Context, req resource.D } // Delete NotificationDiscord current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationDiscordResourceName, err)) diff --git a/internal/provider/notification_email_resource.go b/internal/provider/notification_email_resource.go index e347279..d2434cd 100644 --- a/internal/provider/notification_email_resource.go +++ b/internal/provider/notification_email_resource.go @@ -286,7 +286,7 @@ func (r *NotificationEmailResource) Create(ctx context.Context, req resource.Cre // Create new NotificationEmail request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationEmailResourceName, err)) @@ -310,7 +310,7 @@ func (r *NotificationEmailResource) Read(ctx context.Context, req resource.ReadR } // Get NotificationEmail current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationEmailResourceName, err)) @@ -336,7 +336,7 @@ func (r *NotificationEmailResource) Update(ctx context.Context, req resource.Upd // Update NotificationEmail request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationEmailResourceName, err)) @@ -359,7 +359,7 @@ func (r *NotificationEmailResource) Delete(ctx context.Context, req resource.Del } // Delete NotificationEmail current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationEmailResourceName, err)) diff --git a/internal/provider/notification_goodreads_bookshelves_resource.go b/internal/provider/notification_goodreads_bookshelves_resource.go index d8f7b88..5e74679 100644 --- a/internal/provider/notification_goodreads_bookshelves_resource.go +++ b/internal/provider/notification_goodreads_bookshelves_resource.go @@ -223,7 +223,7 @@ func (r *NotificationGoodreadsBookshelvesResource) Create(ctx context.Context, r // Create new NotificationGoodreadsBookshelves request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationGoodreadsBookshelvesResourceName, err)) @@ -247,7 +247,7 @@ func (r *NotificationGoodreadsBookshelvesResource) Read(ctx context.Context, req } // Get NotificationGoodreadsBookshelves current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationGoodreadsBookshelvesResourceName, err)) @@ -273,7 +273,7 @@ func (r *NotificationGoodreadsBookshelvesResource) Update(ctx context.Context, r // Update NotificationGoodreadsBookshelves request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationGoodreadsBookshelvesResourceName, err)) @@ -296,7 +296,7 @@ func (r *NotificationGoodreadsBookshelvesResource) Delete(ctx context.Context, r } // Delete NotificationGoodreadsBookshelves current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationGoodreadsBookshelvesResourceName, err)) diff --git a/internal/provider/notification_goodreads_owned_books_resource.go b/internal/provider/notification_goodreads_owned_books_resource.go index eca1b6b..fa7600e 100644 --- a/internal/provider/notification_goodreads_owned_books_resource.go +++ b/internal/provider/notification_goodreads_owned_books_resource.go @@ -193,7 +193,7 @@ func (r *NotificationGoodreadsOwnedBooksResource) Create(ctx context.Context, re // Create new NotificationGoodreadsOwnedBooks request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationGoodreadsOwnedBooksResourceName, err)) @@ -217,7 +217,7 @@ func (r *NotificationGoodreadsOwnedBooksResource) Read(ctx context.Context, req } // Get NotificationGoodreadsOwnedBooks current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationGoodreadsOwnedBooksResourceName, err)) @@ -243,7 +243,7 @@ func (r *NotificationGoodreadsOwnedBooksResource) Update(ctx context.Context, re // Update NotificationGoodreadsOwnedBooks request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationGoodreadsOwnedBooksResourceName, err)) @@ -266,7 +266,7 @@ func (r *NotificationGoodreadsOwnedBooksResource) Delete(ctx context.Context, re } // Delete NotificationGoodreadsOwnedBooks current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationGoodreadsOwnedBooksResourceName, err)) diff --git a/internal/provider/notification_gotify_resource.go b/internal/provider/notification_gotify_resource.go index c82e292..a1f3889 100644 --- a/internal/provider/notification_gotify_resource.go +++ b/internal/provider/notification_gotify_resource.go @@ -232,7 +232,7 @@ func (r *NotificationGotifyResource) Create(ctx context.Context, req resource.Cr // Create new NotificationGotify request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationGotifyResourceName, err)) @@ -256,7 +256,7 @@ func (r *NotificationGotifyResource) Read(ctx context.Context, req resource.Read } // Get NotificationGotify current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationGotifyResourceName, err)) @@ -282,7 +282,7 @@ func (r *NotificationGotifyResource) Update(ctx context.Context, req resource.Up // Update NotificationGotify request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationGotifyResourceName, err)) @@ -305,7 +305,7 @@ func (r *NotificationGotifyResource) Delete(ctx context.Context, req resource.De } // Delete NotificationGotify current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationGotifyResourceName, err)) diff --git a/internal/provider/notification_join_resource.go b/internal/provider/notification_join_resource.go index f87885a..d2d89a7 100644 --- a/internal/provider/notification_join_resource.go +++ b/internal/provider/notification_join_resource.go @@ -216,7 +216,7 @@ func (r *NotificationJoinResource) Create(ctx context.Context, req resource.Crea // Create new NotificationJoin request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationJoinResourceName, err)) @@ -240,7 +240,7 @@ func (r *NotificationJoinResource) Read(ctx context.Context, req resource.ReadRe } // Get NotificationJoin current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationJoinResourceName, err)) @@ -266,7 +266,7 @@ func (r *NotificationJoinResource) Update(ctx context.Context, req resource.Upda // Update NotificationJoin request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationJoinResourceName, err)) @@ -289,7 +289,7 @@ func (r *NotificationJoinResource) Delete(ctx context.Context, req resource.Dele } // Delete NotificationJoin current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationJoinResourceName, err)) diff --git a/internal/provider/notification_kavita_resource.go b/internal/provider/notification_kavita_resource.go index c297c9b..c1a80fb 100644 --- a/internal/provider/notification_kavita_resource.go +++ b/internal/provider/notification_kavita_resource.go @@ -194,7 +194,7 @@ func (r *NotificationKavitaResource) Create(ctx context.Context, req resource.Cr // Create new NotificationKavita request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationKavitaResourceName, err)) @@ -218,7 +218,7 @@ func (r *NotificationKavitaResource) Read(ctx context.Context, req resource.Read } // Get NotificationKavita current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationKavitaResourceName, err)) @@ -244,7 +244,7 @@ func (r *NotificationKavitaResource) Update(ctx context.Context, req resource.Up // Update NotificationKavita request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationKavitaResourceName, err)) @@ -267,7 +267,7 @@ func (r *NotificationKavitaResource) Delete(ctx context.Context, req resource.De } // Delete NotificationKavita current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationKavitaResourceName, err)) diff --git a/internal/provider/notification_mailgun_resource.go b/internal/provider/notification_mailgun_resource.go index 51dcd22..1d6c091 100644 --- a/internal/provider/notification_mailgun_resource.go +++ b/internal/provider/notification_mailgun_resource.go @@ -228,7 +228,7 @@ func (r *NotificationMailgunResource) Create(ctx context.Context, req resource.C // Create new NotificationMailgun request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationMailgunResourceName, err)) @@ -252,7 +252,7 @@ func (r *NotificationMailgunResource) Read(ctx context.Context, req resource.Rea } // Get NotificationMailgun current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationMailgunResourceName, err)) @@ -278,7 +278,7 @@ func (r *NotificationMailgunResource) Update(ctx context.Context, req resource.U // Update NotificationMailgun request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationMailgunResourceName, err)) @@ -301,7 +301,7 @@ func (r *NotificationMailgunResource) Delete(ctx context.Context, req resource.D } // Delete NotificationMailgun current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationMailgunResourceName, err)) diff --git a/internal/provider/notification_notifiarr_resource.go b/internal/provider/notification_notifiarr_resource.go index b28aad8..d042bb4 100644 --- a/internal/provider/notification_notifiarr_resource.go +++ b/internal/provider/notification_notifiarr_resource.go @@ -197,7 +197,7 @@ func (r *NotificationNotifiarrResource) Create(ctx context.Context, req resource // Create new NotificationNotifiarr request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationNotifiarrResourceName, err)) @@ -221,7 +221,7 @@ func (r *NotificationNotifiarrResource) Read(ctx context.Context, req resource.R } // Get NotificationNotifiarr current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationNotifiarrResourceName, err)) @@ -247,7 +247,7 @@ func (r *NotificationNotifiarrResource) Update(ctx context.Context, req resource // Update NotificationNotifiarr request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationNotifiarrResourceName, err)) @@ -270,7 +270,7 @@ func (r *NotificationNotifiarrResource) Delete(ctx context.Context, req resource } // Delete NotificationNotifiarr current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationNotifiarrResourceName, err)) diff --git a/internal/provider/notification_ntfy_resource.go b/internal/provider/notification_ntfy_resource.go index d85cc6e..3a9c4ee 100644 --- a/internal/provider/notification_ntfy_resource.go +++ b/internal/provider/notification_ntfy_resource.go @@ -252,7 +252,7 @@ func (r *NotificationNtfyResource) Create(ctx context.Context, req resource.Crea // Create new NotificationNtfy request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationNtfyResourceName, err)) @@ -276,7 +276,7 @@ func (r *NotificationNtfyResource) Read(ctx context.Context, req resource.ReadRe } // Get NotificationNtfy current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationNtfyResourceName, err)) @@ -302,7 +302,7 @@ func (r *NotificationNtfyResource) Update(ctx context.Context, req resource.Upda // Update NotificationNtfy request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationNtfyResourceName, err)) @@ -325,7 +325,7 @@ func (r *NotificationNtfyResource) Delete(ctx context.Context, req resource.Dele } // Delete NotificationNtfy current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationNtfyResourceName, err)) diff --git a/internal/provider/notification_prowl_resource.go b/internal/provider/notification_prowl_resource.go index d6d32c3..3b02738 100644 --- a/internal/provider/notification_prowl_resource.go +++ b/internal/provider/notification_prowl_resource.go @@ -210,7 +210,7 @@ func (r *NotificationProwlResource) Create(ctx context.Context, req resource.Cre // Create new NotificationProwl request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationProwlResourceName, err)) @@ -234,7 +234,7 @@ func (r *NotificationProwlResource) Read(ctx context.Context, req resource.ReadR } // Get NotificationProwl current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationProwlResourceName, err)) @@ -260,7 +260,7 @@ func (r *NotificationProwlResource) Update(ctx context.Context, req resource.Upd // Update NotificationProwl request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationProwlResourceName, err)) @@ -283,7 +283,7 @@ func (r *NotificationProwlResource) Delete(ctx context.Context, req resource.Del } // Delete NotificationProwl current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationProwlResourceName, err)) diff --git a/internal/provider/notification_pushbullet_resource.go b/internal/provider/notification_pushbullet_resource.go index a76baa4..9e79eb8 100644 --- a/internal/provider/notification_pushbullet_resource.go +++ b/internal/provider/notification_pushbullet_resource.go @@ -239,7 +239,7 @@ func (r *NotificationPushbulletResource) Create(ctx context.Context, req resourc // Create new NotificationPushbullet request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationPushbulletResourceName, err)) @@ -263,7 +263,7 @@ func (r *NotificationPushbulletResource) Read(ctx context.Context, req resource. } // Get NotificationPushbullet current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationPushbulletResourceName, err)) @@ -289,7 +289,7 @@ func (r *NotificationPushbulletResource) Update(ctx context.Context, req resourc // Update NotificationPushbullet request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationPushbulletResourceName, err)) @@ -312,7 +312,7 @@ func (r *NotificationPushbulletResource) Delete(ctx context.Context, req resourc } // Delete NotificationPushbullet current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationPushbulletResourceName, err)) diff --git a/internal/provider/notification_pushover_resource.go b/internal/provider/notification_pushover_resource.go index 347a9f3..9109255 100644 --- a/internal/provider/notification_pushover_resource.go +++ b/internal/provider/notification_pushover_resource.go @@ -267,7 +267,7 @@ func (r *NotificationPushoverResource) Create(ctx context.Context, req resource. // Create new NotificationPushover request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationPushoverResourceName, err)) @@ -291,7 +291,7 @@ func (r *NotificationPushoverResource) Read(ctx context.Context, req resource.Re } // Get NotificationPushover current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationPushoverResourceName, err)) @@ -317,7 +317,7 @@ func (r *NotificationPushoverResource) Update(ctx context.Context, req resource. // Update NotificationPushover request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationPushoverResourceName, err)) @@ -340,7 +340,7 @@ func (r *NotificationPushoverResource) Delete(ctx context.Context, req resource. } // Delete NotificationPushover current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationPushoverResourceName, err)) diff --git a/internal/provider/notification_resource.go b/internal/provider/notification_resource.go index 17f99a3..13e0f44 100644 --- a/internal/provider/notification_resource.go +++ b/internal/provider/notification_resource.go @@ -738,7 +738,7 @@ func (r *NotificationResource) Create(ctx context.Context, req resource.CreateRe // Create new Notification request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationResourceName, err)) @@ -765,7 +765,7 @@ func (r *NotificationResource) Read(ctx context.Context, req resource.ReadReques } // Get Notification current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationResourceName, err)) @@ -794,7 +794,7 @@ func (r *NotificationResource) Update(ctx context.Context, req resource.UpdateRe // Update Notification request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationResourceName, err)) @@ -820,7 +820,7 @@ func (r *NotificationResource) Delete(ctx context.Context, req resource.DeleteRe } // Delete Notification current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationResourceName, err)) @@ -871,7 +871,11 @@ func (n *Notification) write(ctx context.Context, notification *readarr.Notifica n.Bcc = types.SetValueMust(types.StringType, nil) n.AddIds = types.SetValueMust(types.StringType, nil) n.RemoveIds = types.SetValueMust(types.StringType, nil) - helpers.WriteFields(ctx, n, notification.GetFields(), notificationFields) + fields := make([]*readarr.Field, len(notification.GetFields())) + for i := range notification.GetFields() { + fields[i] = ¬ification.GetFields()[i] + } + helpers.WriteFields(ctx, n, fields, notificationFields) } func (n *Notification) read(ctx context.Context, diags *diag.Diagnostics) *readarr.NotificationResource { @@ -895,7 +899,11 @@ func (n *Notification) read(ctx context.Context, diags *diag.Diagnostics) *reada notification.SetImplementation(n.Implementation.ValueString()) notification.SetConfigContract(n.ConfigContract.ValueString()) diags.Append(n.Tags.ElementsAs(ctx, ¬ification.Tags, true)...) - notification.SetFields(helpers.ReadFields(ctx, n, notificationFields)) + fields := make([]readarr.Field, len(helpers.ReadFields(ctx, n, notificationFields))) + for i, f := range helpers.ReadFields(ctx, n, notificationFields) { + fields[i] = *f + } + notification.SetFields(fields) return notification } diff --git a/internal/provider/notification_sendgrid_resource.go b/internal/provider/notification_sendgrid_resource.go index 56f6963..8358087 100644 --- a/internal/provider/notification_sendgrid_resource.go +++ b/internal/provider/notification_sendgrid_resource.go @@ -229,7 +229,7 @@ func (r *NotificationSendgridResource) Create(ctx context.Context, req resource. // Create new NotificationSendgrid request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationSendgridResourceName, err)) @@ -253,7 +253,7 @@ func (r *NotificationSendgridResource) Read(ctx context.Context, req resource.Re } // Get NotificationSendgrid current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationSendgridResourceName, err)) @@ -279,7 +279,7 @@ func (r *NotificationSendgridResource) Update(ctx context.Context, req resource. // Update NotificationSendgrid request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationSendgridResourceName, err)) @@ -302,7 +302,7 @@ func (r *NotificationSendgridResource) Delete(ctx context.Context, req resource. } // Delete NotificationSendgrid current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationSendgridResourceName, err)) diff --git a/internal/provider/notification_slack_resource.go b/internal/provider/notification_slack_resource.go index 817c624..cee8b1b 100644 --- a/internal/provider/notification_slack_resource.go +++ b/internal/provider/notification_slack_resource.go @@ -251,7 +251,7 @@ func (r *NotificationSlackResource) Create(ctx context.Context, req resource.Cre // Create new NotificationSlack request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationSlackResourceName, err)) @@ -275,7 +275,7 @@ func (r *NotificationSlackResource) Read(ctx context.Context, req resource.ReadR } // Get NotificationSlack current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationSlackResourceName, err)) @@ -301,7 +301,7 @@ func (r *NotificationSlackResource) Update(ctx context.Context, req resource.Upd // Update NotificationSlack request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationSlackResourceName, err)) @@ -324,7 +324,7 @@ func (r *NotificationSlackResource) Delete(ctx context.Context, req resource.Del } // Delete NotificationSlack current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationSlackResourceName, err)) diff --git a/internal/provider/notification_subsonic_resource.go b/internal/provider/notification_subsonic_resource.go index 6476798..1739573 100644 --- a/internal/provider/notification_subsonic_resource.go +++ b/internal/provider/notification_subsonic_resource.go @@ -268,7 +268,7 @@ func (r *NotificationSubsonicResource) Create(ctx context.Context, req resource. // Create new NotificationSubsonic request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationSubsonicResourceName, err)) @@ -292,7 +292,7 @@ func (r *NotificationSubsonicResource) Read(ctx context.Context, req resource.Re } // Get NotificationSubsonic current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationSubsonicResourceName, err)) @@ -318,7 +318,7 @@ func (r *NotificationSubsonicResource) Update(ctx context.Context, req resource. // Update NotificationSubsonic request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationSubsonicResourceName, err)) @@ -341,7 +341,7 @@ func (r *NotificationSubsonicResource) Delete(ctx context.Context, req resource. } // Delete NotificationSubsonic current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationSubsonicResourceName, err)) diff --git a/internal/provider/notification_synology_indexer_resource.go b/internal/provider/notification_synology_indexer_resource.go index 88338c2..defeee3 100644 --- a/internal/provider/notification_synology_indexer_resource.go +++ b/internal/provider/notification_synology_indexer_resource.go @@ -181,7 +181,7 @@ func (r *NotificationSynologyResource) Create(ctx context.Context, req resource. // Create new NotificationSynology request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationSynologyResourceName, err)) @@ -205,7 +205,7 @@ func (r *NotificationSynologyResource) Read(ctx context.Context, req resource.Re } // Get NotificationSynology current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationSynologyResourceName, err)) @@ -231,7 +231,7 @@ func (r *NotificationSynologyResource) Update(ctx context.Context, req resource. // Update NotificationSynology request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationSynologyResourceName, err)) @@ -254,7 +254,7 @@ func (r *NotificationSynologyResource) Delete(ctx context.Context, req resource. } // Delete NotificationSynology current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationSynologyResourceName, err)) diff --git a/internal/provider/notification_telegram_resource.go b/internal/provider/notification_telegram_resource.go index b6dc8ab..e84ce04 100644 --- a/internal/provider/notification_telegram_resource.go +++ b/internal/provider/notification_telegram_resource.go @@ -228,7 +228,7 @@ func (r *NotificationTelegramResource) Create(ctx context.Context, req resource. // Create new NotificationTelegram request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationTelegramResourceName, err)) @@ -252,7 +252,7 @@ func (r *NotificationTelegramResource) Read(ctx context.Context, req resource.Re } // Get NotificationTelegram current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationTelegramResourceName, err)) @@ -278,7 +278,7 @@ func (r *NotificationTelegramResource) Update(ctx context.Context, req resource. // Update NotificationTelegram request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationTelegramResourceName, err)) @@ -301,7 +301,7 @@ func (r *NotificationTelegramResource) Delete(ctx context.Context, req resource. } // Delete NotificationTelegram current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationTelegramResourceName, err)) diff --git a/internal/provider/notification_twitter_resource.go b/internal/provider/notification_twitter_resource.go index 8a87e74..1bf77dd 100644 --- a/internal/provider/notification_twitter_resource.go +++ b/internal/provider/notification_twitter_resource.go @@ -252,7 +252,7 @@ func (r *NotificationTwitterResource) Create(ctx context.Context, req resource.C // Create new NotificationTwitter request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationTwitterResourceName, err)) @@ -276,7 +276,7 @@ func (r *NotificationTwitterResource) Read(ctx context.Context, req resource.Rea } // Get NotificationTwitter current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationTwitterResourceName, err)) @@ -302,7 +302,7 @@ func (r *NotificationTwitterResource) Update(ctx context.Context, req resource.U // Update NotificationTwitter request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationTwitterResourceName, err)) @@ -325,7 +325,7 @@ func (r *NotificationTwitterResource) Delete(ctx context.Context, req resource.D } // Delete NotificationTwitter current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationTwitterResourceName, err)) diff --git a/internal/provider/notification_webhook_resource.go b/internal/provider/notification_webhook_resource.go index 2a32f91..84ce2a2 100644 --- a/internal/provider/notification_webhook_resource.go +++ b/internal/provider/notification_webhook_resource.go @@ -241,7 +241,7 @@ func (r *NotificationWebhookResource) Create(ctx context.Context, req resource.C // Create new NotificationWebhook request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.CreateNotification(ctx).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.CreateNotification(ctx).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, notificationWebhookResourceName, err)) @@ -265,7 +265,7 @@ func (r *NotificationWebhookResource) Read(ctx context.Context, req resource.Rea } // Get NotificationWebhook current value - response, _, err := r.client.NotificationApi.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() + response, _, err := r.client.NotificationAPI.GetNotificationById(ctx, int32(notification.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationWebhookResourceName, err)) @@ -291,7 +291,7 @@ func (r *NotificationWebhookResource) Update(ctx context.Context, req resource.U // Update NotificationWebhook request := notification.read(ctx, &resp.Diagnostics) - response, _, err := r.client.NotificationApi.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() + response, _, err := r.client.NotificationAPI.UpdateNotification(ctx, strconv.Itoa(int(request.GetId()))).NotificationResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, notificationWebhookResourceName, err)) @@ -314,7 +314,7 @@ func (r *NotificationWebhookResource) Delete(ctx context.Context, req resource.D } // Delete NotificationWebhook current value - _, err := r.client.NotificationApi.DeleteNotification(ctx, int32(ID)).Execute() + _, err := r.client.NotificationAPI.DeleteNotification(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, notificationWebhookResourceName, err)) diff --git a/internal/provider/notifications_data_source.go b/internal/provider/notifications_data_source.go index ed3af7b..3e8eb61 100644 --- a/internal/provider/notifications_data_source.go +++ b/internal/provider/notifications_data_source.go @@ -436,7 +436,7 @@ func (d *NotificationsDataSource) Configure(ctx context.Context, req datasource. func (d *NotificationsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get notifications current value - response, _, err := d.client.NotificationApi.ListNotification(ctx).Execute() + response, _, err := d.client.NotificationAPI.ListNotification(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, notificationsDataSourceName, err)) @@ -447,7 +447,7 @@ func (d *NotificationsDataSource) Read(ctx context.Context, _ datasource.ReadReq // Map response body to resource schema attribute notifications := make([]Notification, len(response)) for i, n := range response { - notifications[i].write(ctx, n, &resp.Diagnostics) + notifications[i].write(ctx, &n, &resp.Diagnostics) } notificationList, diags := types.SetValueFrom(ctx, Notification{}.getType(), notifications) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index c9bf27c..1076987 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -121,7 +121,7 @@ func (p *ReadarrProvider) Configure(ctx context.Context, req provider.ConfigureR // Configuring client. API Key management could be changed once new options avail in sdk. config := readarr.NewConfiguration() - config.AddDefaultHeader("X-Api-Key", key) + config.AddDefaultHeader("X-API-Key", key) config.Servers[0].URL = url client := readarr.NewAPIClient(config) diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index dec3ee0..3d344dc 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -31,7 +31,7 @@ func testAccPreCheck(t *testing.T) { func testAccAPIClient() *readarr.APIClient { config := readarr.NewConfiguration() - config.AddDefaultHeader("X-Api-Key", os.Getenv("READARR_API_KEY")) + config.AddDefaultHeader("X-API-Key", os.Getenv("READARR_API_KEY")) config.Servers[0].URL = os.Getenv("READARR_URL") return readarr.NewAPIClient(config) diff --git a/internal/provider/quality_data_source.go b/internal/provider/quality_data_source.go index 58eadc0..a612191 100644 --- a/internal/provider/quality_data_source.go +++ b/internal/provider/quality_data_source.go @@ -77,14 +77,18 @@ func (d *QualityDataSource) Read(ctx context.Context, req datasource.ReadRequest return } // Get qualitys current value - response, _, err := d.client.QualityDefinitionApi.ListQualityDefinition(ctx).Execute() + response, _, err := d.client.QualityDefinitionAPI.ListQualityDefinition(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityDataSourceName, err)) return } - data.find(data.Name.ValueString(), response, &resp.Diagnostics) + qualities := make([]*readarr.QualityDefinitionResource, len(response)) + for i := range response { + qualities[i] = &response[i] + } + data.find(data.Name.ValueString(), qualities, &resp.Diagnostics) tflog.Trace(ctx, "read "+qualityDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/quality_definition_data_source.go b/internal/provider/quality_definition_data_source.go index 99c163c..30e2a6f 100644 --- a/internal/provider/quality_definition_data_source.go +++ b/internal/provider/quality_definition_data_source.go @@ -79,14 +79,18 @@ func (d *QualityDefinitionDataSource) Read(ctx context.Context, req datasource.R return } // Get qualitydefinitions current value - response, _, err := d.client.QualityDefinitionApi.ListQualityDefinition(ctx).Execute() + response, _, err := d.client.QualityDefinitionAPI.ListQualityDefinition(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityDefinitionDataSourceName, err)) return } - data.find(data.ID.ValueInt64(), response, &resp.Diagnostics) + definitions := make([]*readarr.QualityDefinitionResource, len(response)) + for i := range response { + definitions[i] = &response[i] + } + data.find(data.ID.ValueInt64(), definitions, &resp.Diagnostics) tflog.Trace(ctx, "read "+qualityDefinitionDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/quality_definition_resource.go b/internal/provider/quality_definition_resource.go index 5c15130..d07205a 100644 --- a/internal/provider/quality_definition_resource.go +++ b/internal/provider/quality_definition_resource.go @@ -116,7 +116,7 @@ func (r *QualityDefinitionResource) Create(ctx context.Context, req resource.Cre request := definition.read() // Read to get the quality ID - read, _, err := r.client.QualityDefinitionApi.GetQualityDefinitionById(ctx, request.GetId()).Execute() + read, _, err := r.client.QualityDefinitionAPI.GetQualityDefinitionById(ctx, request.GetId()).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, qualityDefinitionResourceName, err)) @@ -126,7 +126,7 @@ func (r *QualityDefinitionResource) Create(ctx context.Context, req resource.Cre request.Quality.SetId(read.Quality.GetId()) // Create new QualityDefinition - response, _, err := r.client.QualityDefinitionApi.UpdateQualityDefinition(ctx, strconv.Itoa(int(request.GetId()))).QualityDefinitionResource(*request).Execute() + response, _, err := r.client.QualityDefinitionAPI.UpdateQualityDefinition(ctx, strconv.Itoa(int(request.GetId()))).QualityDefinitionResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, qualityDefinitionResourceName, err)) @@ -150,7 +150,7 @@ func (r *QualityDefinitionResource) Read(ctx context.Context, req resource.ReadR } // Get qualitydefinition current value - response, _, err := r.client.QualityDefinitionApi.GetQualityDefinitionById(ctx, int32(definition.ID.ValueInt64())).Execute() + response, _, err := r.client.QualityDefinitionAPI.GetQualityDefinitionById(ctx, int32(definition.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityDefinitionResourceName, err)) @@ -177,7 +177,7 @@ func (r *QualityDefinitionResource) Update(ctx context.Context, req resource.Upd request := definition.read() // Update QualityDefinition - response, _, err := r.client.QualityDefinitionApi.UpdateQualityDefinition(ctx, strconv.Itoa(int(request.GetId()))).QualityDefinitionResource(*request).Execute() + response, _, err := r.client.QualityDefinitionAPI.UpdateQualityDefinition(ctx, strconv.Itoa(int(request.GetId()))).QualityDefinitionResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, qualityDefinitionResourceName, err)) diff --git a/internal/provider/quality_definitions_data_source.go b/internal/provider/quality_definitions_data_source.go index 53af687..66c79f1 100644 --- a/internal/provider/quality_definitions_data_source.go +++ b/internal/provider/quality_definitions_data_source.go @@ -90,7 +90,7 @@ func (d *QualityDefinitionsDataSource) Configure(ctx context.Context, req dataso func (d *QualityDefinitionsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get qualitydefinitions current value - response, _, err := d.client.QualityDefinitionApi.ListQualityDefinition(ctx).Execute() + response, _, err := d.client.QualityDefinitionAPI.ListQualityDefinition(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityDefinitionsDataSourceName, err)) @@ -101,7 +101,7 @@ func (d *QualityDefinitionsDataSource) Read(ctx context.Context, _ datasource.Re // Map response body to resource schema attribute definitions := make([]QualityDefinition, len(response)) for i, p := range response { - definitions[i].write(p) + definitions[i].write(&p) } qualityList, diags := types.SetValueFrom(ctx, QualityDefinition{}.getType(), definitions) diff --git a/internal/provider/quality_profile_data_source.go b/internal/provider/quality_profile_data_source.go index 98b5a9e..eeb7db5 100644 --- a/internal/provider/quality_profile_data_source.go +++ b/internal/provider/quality_profile_data_source.go @@ -129,14 +129,18 @@ func (d *QualityProfileDataSource) Read(ctx context.Context, req datasource.Read return } // Get qualityprofiles current value - response, _, err := d.client.QualityProfileApi.ListQualityProfile(ctx).Execute() + response, _, err := d.client.QualityProfileAPI.ListQualityProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityProfileDataSourceName, err)) return } - data.find(ctx, data.Name.ValueString(), response, &resp.Diagnostics) + profiles := make([]*readarr.QualityProfileResource, len(response)) + for i := range response { + profiles[i] = &response[i] + } + data.find(ctx, data.Name.ValueString(), profiles, &resp.Diagnostics) tflog.Trace(ctx, "read "+qualityProfileDataSourceName) // Map response body to resource schema attribute diff --git a/internal/provider/quality_profile_resource.go b/internal/provider/quality_profile_resource.go index 9e997e0..e9a9875 100644 --- a/internal/provider/quality_profile_resource.go +++ b/internal/provider/quality_profile_resource.go @@ -242,7 +242,7 @@ func (r *QualityProfileResource) Create(ctx context.Context, req resource.Create request := profile.read(ctx, r.getQualityIDs(ctx, &resp.Diagnostics), r.getFormatsIDs(ctx, &resp.Diagnostics), &resp.Diagnostics) // Create new QualityProfile - response, _, err := r.client.QualityProfileApi.CreateQualityProfile(ctx).QualityProfileResource(*request).Execute() + response, _, err := r.client.QualityProfileAPI.CreateQualityProfile(ctx).QualityProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, qualityProfileResourceName, err)) @@ -266,7 +266,7 @@ func (r *QualityProfileResource) Read(ctx context.Context, req resource.ReadRequ } // Get qualityprofile current value - response, _, err := r.client.QualityProfileApi.GetQualityProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() + response, _, err := r.client.QualityProfileAPI.GetQualityProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityProfileResourceName, err)) @@ -293,7 +293,7 @@ func (r *QualityProfileResource) Update(ctx context.Context, req resource.Update request := profile.read(ctx, r.getQualityIDs(ctx, &resp.Diagnostics), r.getFormatsIDs(ctx, &resp.Diagnostics), &resp.Diagnostics) // Update QualityProfile - response, _, err := r.client.QualityProfileApi.UpdateQualityProfile(ctx, strconv.Itoa(int(request.GetId()))).QualityProfileResource(*request).Execute() + response, _, err := r.client.QualityProfileAPI.UpdateQualityProfile(ctx, strconv.Itoa(int(request.GetId()))).QualityProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, qualityProfileResourceName, err)) @@ -316,7 +316,7 @@ func (r *QualityProfileResource) Delete(ctx context.Context, req resource.Delete } // Delete qualityprofile current value - _, err := r.client.QualityProfileApi.DeleteQualityProfile(ctx, int32(ID)).Execute() + _, err := r.client.QualityProfileAPI.DeleteQualityProfile(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, qualityProfileResourceName, err)) @@ -347,7 +347,7 @@ func (p *QualityProfile) write(ctx context.Context, profile *readarr.QualityProf for _, g := range profile.GetItems() { if g.GetAllowed() { group := QualityGroup{} - group.write(ctx, g, diags) + group.write(ctx, &g, diags) qualityGroups = append(qualityGroups, group) } } @@ -357,7 +357,7 @@ func (p *QualityProfile) write(ctx context.Context, profile *readarr.QualityProf for _, f := range profile.GetFormatItems() { if f.GetScore() != 0 { format := FormatItem{} - format.write(f) + format.write(&f) formatItems = append(formatItems, format) } } @@ -377,7 +377,7 @@ func (g *QualityGroup) write(ctx context.Context, group *readarr.QualityProfileQ qualities := make([]Quality, len(group.GetItems())) for m, q := range group.GetItems() { - qualities[m].write(q) + qualities[m].write(&q) } if len(group.GetItems()) == 0 { @@ -408,7 +408,6 @@ func (f *FormatItem) write(format *readarr.ProfileFormatItemResource) { func (p *QualityProfile) read(ctx context.Context, qualitiesIDs []int32, formatIDs []int32, diags *diag.Diagnostics) *readarr.QualityProfileResource { var allowedQualities, allowedFormats []int32 - groups := make([]QualityGroup, len(p.QualityGroups.Elements())) diags.Append(p.QualityGroups.ElementsAs(ctx, &groups, false)...) @@ -423,12 +422,10 @@ func (p *QualityProfile) read(ctx context.Context, qualitiesIDs []int32, formatI if !slices.Contains(allowedQualities, id) { quality := readarr.NewQuality() quality.SetId(id) - item := readarr.NewQualityProfileQualityItemResource() item.SetAllowed(false) - item.SetItems([]*readarr.QualityProfileQualityItemResource{}) + item.SetItems([]readarr.QualityProfileQualityItemResource{}) item.SetQuality(*quality) - qualities = append(qualities, item) } } @@ -455,6 +452,17 @@ func (p *QualityProfile) read(ctx context.Context, qualitiesIDs []int32, formatI } } + // Convert pointer slices to value slices + qualityItems := make([]readarr.QualityProfileQualityItemResource, len(qualities)) + for i, q := range qualities { + qualityItems[i] = *q + } + + formatList := make([]readarr.ProfileFormatItemResource, len(formatItems)) + for i, f := range formatItems { + formatList[i] = *f + } + profile := readarr.NewQualityProfileResource() profile.SetUpgradeAllowed(p.UpgradeAllowed.ValueBool()) profile.SetId(int32(p.ID.ValueInt64())) @@ -462,8 +470,8 @@ func (p *QualityProfile) read(ctx context.Context, qualitiesIDs []int32, formatI profile.SetMinFormatScore(int32(p.MinFormatScore.ValueInt64())) profile.SetCutoffFormatScore(int32(p.CutoffFormatScore.ValueInt64())) profile.SetName(p.Name.ValueString()) - profile.SetItems(qualities) - profile.SetFormatItems(formatItems) + profile.SetItems(qualityItems) + profile.SetFormatItems(formatList) return profile } @@ -496,7 +504,11 @@ func (g *QualityGroup) read(ctx context.Context, allowedQualities *[]int32, diag quality.SetId(int32(g.ID.ValueInt64())) quality.SetName(g.Name.ValueString()) quality.SetAllowed(true) - quality.SetItems(items) + qualityItems := make([]readarr.QualityProfileQualityItemResource, len(items)) + for i, item := range items { + qualityItems[i] = *item + } + quality.SetItems(qualityItems) return quality } @@ -524,7 +536,7 @@ func (f *FormatItem) read() *readarr.ProfileFormatItemResource { func (r QualityProfileResource) getQualityIDs(ctx context.Context, diags *diag.Diagnostics) []int32 { // Get qualitydefinitions current value - qualities, _, err := r.client.QualityDefinitionApi.ListQualityDefinition(ctx).Execute() + qualities, _, err := r.client.QualityDefinitionAPI.ListQualityDefinition(ctx).Execute() if err != nil { diags.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityDefinitionsDataSourceName, err)) @@ -545,7 +557,7 @@ func (r QualityProfileResource) getQualityIDs(ctx context.Context, diags *diag.D func (r QualityProfileResource) getFormatsIDs(ctx context.Context, diags *diag.Diagnostics) []int32 { // Get qualitydefinitions current value - formats, _, err := r.client.CustomFormatApi.ListCustomFormat(ctx).Execute() + formats, _, err := r.client.CustomFormatAPI.ListCustomFormat(ctx).Execute() if err != nil { diags.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, customFormatsDataSourceName, err)) diff --git a/internal/provider/quality_profiles_data_source.go b/internal/provider/quality_profiles_data_source.go index 63ca6a3..e99e1de 100644 --- a/internal/provider/quality_profiles_data_source.go +++ b/internal/provider/quality_profiles_data_source.go @@ -141,7 +141,7 @@ func (d *QualityProfilesDataSource) Configure(ctx context.Context, req datasourc func (d *QualityProfilesDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get qualityprofiles current value - response, _, err := d.client.QualityProfileApi.ListQualityProfile(ctx).Execute() + response, _, err := d.client.QualityProfileAPI.ListQualityProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, qualityProfilesDataSourceName, err)) @@ -152,7 +152,7 @@ func (d *QualityProfilesDataSource) Read(ctx context.Context, _ datasource.ReadR // Map response body to resource schema attribute profiles := make([]QualityProfile, len(response)) for i, p := range response { - profiles[i].write(ctx, p, &resp.Diagnostics) + profiles[i].write(ctx, &p, &resp.Diagnostics) } profileList, diags := types.SetValueFrom(ctx, QualityProfile{}.getType(), profiles) diff --git a/internal/provider/release_profile_data_source.go b/internal/provider/release_profile_data_source.go index b8c94f6..bb0c82f 100644 --- a/internal/provider/release_profile_data_source.go +++ b/internal/provider/release_profile_data_source.go @@ -82,14 +82,18 @@ func (d *ReleaseProfileDataSource) Read(ctx context.Context, req datasource.Read return } // Get releaseprofiles current value - response, _, err := d.client.ReleaseProfileApi.ListReleaseProfile(ctx).Execute() + response, _, err := d.client.ReleaseProfileAPI.ListReleaseProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, releaseProfileDataSourceName, err)) return } - data.find(ctx, data.ID.ValueInt64(), response, &resp.Diagnostics) + profiles := make([]*readarr.ReleaseProfileResource, len(response)) + for i := range response { + profiles[i] = &response[i] + } + data.find(ctx, data.ID.ValueInt64(), profiles, &resp.Diagnostics) tflog.Trace(ctx, "read "+releaseProfileDataSourceName) // Map response body to resource schema attribute diff --git a/internal/provider/release_profile_resource.go b/internal/provider/release_profile_resource.go index 4d1c57c..0c63e82 100644 --- a/internal/provider/release_profile_resource.go +++ b/internal/provider/release_profile_resource.go @@ -128,7 +128,7 @@ func (r *ReleaseProfileResource) Create(ctx context.Context, req resource.Create request := profile.read(ctx, &resp.Diagnostics) // Create new ReleaseProfile - response, _, err := r.client.ReleaseProfileApi.CreateReleaseProfile(ctx).ReleaseProfileResource(*request).Execute() + response, _, err := r.client.ReleaseProfileAPI.CreateReleaseProfile(ctx).ReleaseProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, releaseProfileResourceName, err)) @@ -152,7 +152,7 @@ func (r *ReleaseProfileResource) Read(ctx context.Context, req resource.ReadRequ } // Get releaseprofile current value - response, _, err := r.client.ReleaseProfileApi.GetReleaseProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() + response, _, err := r.client.ReleaseProfileAPI.GetReleaseProfileById(ctx, int32(profile.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, releaseProfileResourceName, err)) @@ -179,7 +179,7 @@ func (r *ReleaseProfileResource) Update(ctx context.Context, req resource.Update request := profile.read(ctx, &resp.Diagnostics) // Update ReleaseProfile - response, _, err := r.client.ReleaseProfileApi.UpdateReleaseProfile(ctx, strconv.Itoa(int(request.GetId()))).ReleaseProfileResource(*request).Execute() + response, _, err := r.client.ReleaseProfileAPI.UpdateReleaseProfile(ctx, strconv.Itoa(int(request.GetId()))).ReleaseProfileResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, releaseProfileResourceName, err)) @@ -202,7 +202,7 @@ func (r *ReleaseProfileResource) Delete(ctx context.Context, req resource.Delete } // Delete releaseprofile current value - _, err := r.client.ReleaseProfileApi.DeleteReleaseProfile(ctx, int32(ID)).Execute() + _, err := r.client.ReleaseProfileAPI.DeleteReleaseProfile(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, releaseProfileResourceName, err)) diff --git a/internal/provider/release_profiles_data_source.go b/internal/provider/release_profiles_data_source.go index 4151324..8fa38c6 100644 --- a/internal/provider/release_profiles_data_source.go +++ b/internal/provider/release_profiles_data_source.go @@ -92,7 +92,7 @@ func (d *ReleaseProfilesDataSource) Configure(ctx context.Context, req datasourc func (d *ReleaseProfilesDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get releaseprofiles current value - response, _, err := d.client.ReleaseProfileApi.ListReleaseProfile(ctx).Execute() + response, _, err := d.client.ReleaseProfileAPI.ListReleaseProfile(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, releaseProfileResourceName, err)) @@ -103,7 +103,7 @@ func (d *ReleaseProfilesDataSource) Read(ctx context.Context, _ datasource.ReadR // Map response body to resource schema attribute profiles := make([]ReleaseProfile, len(response)) for i, p := range response { - profiles[i].write(ctx, p, &resp.Diagnostics) + profiles[i].write(ctx, &p, &resp.Diagnostics) } profileList, diags := types.SetValueFrom(ctx, ReleaseProfile{}.getType(), profiles) diff --git a/internal/provider/remote_path_mapping_data_source.go b/internal/provider/remote_path_mapping_data_source.go index 51d2c40..56e5119 100644 --- a/internal/provider/remote_path_mapping_data_source.go +++ b/internal/provider/remote_path_mapping_data_source.go @@ -70,14 +70,18 @@ func (d *RemotePathMappingDataSource) Read(ctx context.Context, req datasource.R return } // Get remote path mapping current value - response, _, err := d.client.RemotePathMappingApi.ListRemotePathMapping(ctx).Execute() + response, _, err := d.client.RemotePathMappingAPI.ListRemotePathMapping(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, remotePathMappingDataSourceName, err)) return } - data.find(data.ID.ValueInt64(), response, &resp.Diagnostics) + mappings := make([]*readarr.RemotePathMappingResource, len(response)) + for i := range response { + mappings[i] = &response[i] + } + data.find(data.ID.ValueInt64(), mappings, &resp.Diagnostics) tflog.Trace(ctx, "read "+remotePathMappingDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/remote_path_mapping_resource.go b/internal/provider/remote_path_mapping_resource.go index f393444..961e371 100644 --- a/internal/provider/remote_path_mapping_resource.go +++ b/internal/provider/remote_path_mapping_resource.go @@ -101,7 +101,7 @@ func (r *RemotePathMappingResource) Create(ctx context.Context, req resource.Cre // Create new RemotePathMapping request := mapping.read() - response, _, err := r.client.RemotePathMappingApi.CreateRemotePathMapping(ctx).RemotePathMappingResource(*request).Execute() + response, _, err := r.client.RemotePathMappingAPI.CreateRemotePathMapping(ctx).RemotePathMappingResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, remotePathMappingResourceName, err)) @@ -125,7 +125,7 @@ func (r *RemotePathMappingResource) Read(ctx context.Context, req resource.ReadR } // Get remotePathMapping current value - response, _, err := r.client.RemotePathMappingApi.GetRemotePathMappingById(ctx, int32(mapping.ID.ValueInt64())).Execute() + response, _, err := r.client.RemotePathMappingAPI.GetRemotePathMappingById(ctx, int32(mapping.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, remotePathMappingResourceName, err)) @@ -151,7 +151,7 @@ func (r *RemotePathMappingResource) Update(ctx context.Context, req resource.Upd // Update RemotePathMapping request := mapping.read() - response, _, err := r.client.RemotePathMappingApi.UpdateRemotePathMapping(ctx, strconv.Itoa(int(request.GetId()))).RemotePathMappingResource(*request).Execute() + response, _, err := r.client.RemotePathMappingAPI.UpdateRemotePathMapping(ctx, strconv.Itoa(int(request.GetId()))).RemotePathMappingResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, remotePathMappingResourceName, err)) @@ -174,7 +174,7 @@ func (r *RemotePathMappingResource) Delete(ctx context.Context, req resource.Del } // Delete remotePathMapping current value - _, err := r.client.RemotePathMappingApi.DeleteRemotePathMapping(ctx, int32(ID)).Execute() + _, err := r.client.RemotePathMappingAPI.DeleteRemotePathMapping(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, remotePathMappingResourceName, err)) diff --git a/internal/provider/remote_path_mappings_data_source.go b/internal/provider/remote_path_mappings_data_source.go index e722cb7..8e23201 100644 --- a/internal/provider/remote_path_mappings_data_source.go +++ b/internal/provider/remote_path_mappings_data_source.go @@ -81,7 +81,7 @@ func (d *RemotePathMappingsDataSource) Configure(ctx context.Context, req dataso func (d *RemotePathMappingsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get remotePathMappings current value - response, _, err := d.client.RemotePathMappingApi.ListRemotePathMapping(ctx).Execute() + response, _, err := d.client.RemotePathMappingAPI.ListRemotePathMapping(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, remotePathMappingsDataSourceName, err)) @@ -92,7 +92,7 @@ func (d *RemotePathMappingsDataSource) Read(ctx context.Context, _ datasource.Re // Map response body to resource schema attribute mappings := make([]RemotePathMapping, len(response)) for i, p := range response { - mappings[i].write(p) + mappings[i].write(&p) } pathList, diags := types.SetValueFrom(ctx, RemotePathMapping{}.getType(), mappings) diff --git a/internal/provider/root_folder_data_source.go b/internal/provider/root_folder_data_source.go index 4b403b0..976a2ad 100644 --- a/internal/provider/root_folder_data_source.go +++ b/internal/provider/root_folder_data_source.go @@ -124,14 +124,18 @@ func (d *RootFolderDataSource) Read(ctx context.Context, req datasource.ReadRequ return } // Get rootfolders current value - response, _, err := d.client.RootFolderApi.ListRootFolder(ctx).Execute() + response, _, err := d.client.RootFolderAPI.ListRootFolder(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, rootFolderDataSourceName, err)) return } - folder.find(ctx, folder.Path.ValueString(), response, &resp.Diagnostics) + folders := make([]*readarr.RootFolderResource, len(response)) + for i := range response { + folders[i] = &response[i] + } + folder.find(ctx, folder.Path.ValueString(), folders, &resp.Diagnostics) tflog.Trace(ctx, "read "+rootFolderDataSourceName) // Map response body to resource schema attribute diff --git a/internal/provider/root_folder_data_source_test.go b/internal/provider/root_folder_data_source_test.go index dd24928..0e41b36 100644 --- a/internal/provider/root_folder_data_source_test.go +++ b/internal/provider/root_folder_data_source_test.go @@ -59,6 +59,7 @@ func rootFolderDSInit() { folder.SetHost("") folder.SetIsCalibreLibrary(false) folder.SetName("Config") - folder.SetDefaultTags([]*int32{}) - _, _, _ = client.RootFolderApi.CreateRootFolder(context.TODO()).RootFolderResource(*folder).Execute() + tags := make([]int32, 0) + folder.SetDefaultTags(tags) + _, _, _ = client.RootFolderAPI.CreateRootFolder(context.TODO()).RootFolderResource(*folder).Execute() } diff --git a/internal/provider/root_folder_resource.go b/internal/provider/root_folder_resource.go index 5783dad..a6a567e 100644 --- a/internal/provider/root_folder_resource.go +++ b/internal/provider/root_folder_resource.go @@ -203,7 +203,7 @@ func (r *RootFolderResource) Create(ctx context.Context, req resource.CreateRequ // Create new RootFolder request := folder.read(ctx, &resp.Diagnostics) - response, _, err := r.client.RootFolderApi.CreateRootFolder(ctx).RootFolderResource(*request).Execute() + response, _, err := r.client.RootFolderAPI.CreateRootFolder(ctx).RootFolderResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, rootFolderResourceName, err)) @@ -227,7 +227,7 @@ func (r *RootFolderResource) Read(ctx context.Context, req resource.ReadRequest, } // Get rootFolder current value - response, _, err := r.client.RootFolderApi.GetRootFolderById(ctx, int32(folder.ID.ValueInt64())).Execute() + response, _, err := r.client.RootFolderAPI.GetRootFolderById(ctx, int32(folder.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, rootFolderResourceName, err)) @@ -253,7 +253,7 @@ func (r *RootFolderResource) Update(ctx context.Context, req resource.UpdateRequ // Update RootFolder request := folder.read(ctx, &resp.Diagnostics) - response, _, err := r.client.RootFolderApi.UpdateRootFolder(ctx, strconv.Itoa(int(request.GetId()))).RootFolderResource(*request).Execute() + response, _, err := r.client.RootFolderAPI.UpdateRootFolder(ctx, strconv.Itoa(int(request.GetId()))).RootFolderResource(*request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, rootFolderResourceName, err)) @@ -276,7 +276,7 @@ func (r *RootFolderResource) Delete(ctx context.Context, req resource.DeleteRequ } // Delete rootFolder current value - _, err := r.client.RootFolderApi.DeleteRootFolder(ctx, int32(ID)).Execute() + _, err := r.client.RootFolderAPI.DeleteRootFolder(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, rootFolderResourceName, err)) diff --git a/internal/provider/root_folders_data_source.go b/internal/provider/root_folders_data_source.go index b0b8b1d..7dd42a2 100644 --- a/internal/provider/root_folders_data_source.go +++ b/internal/provider/root_folders_data_source.go @@ -135,7 +135,7 @@ func (d *RootFoldersDataSource) Configure(ctx context.Context, req datasource.Co func (d *RootFoldersDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get rootfolders current value - response, _, err := d.client.RootFolderApi.ListRootFolder(ctx).Execute() + response, _, err := d.client.RootFolderAPI.ListRootFolder(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, rootFoldersDataSourceName, err)) @@ -146,7 +146,7 @@ func (d *RootFoldersDataSource) Read(ctx context.Context, _ datasource.ReadReque // Map response body to resource schema attribute rootFolders := make([]RootFolder, len(response)) for i, f := range response { - rootFolders[i].write(ctx, f, &resp.Diagnostics) + rootFolders[i].write(ctx, &f, &resp.Diagnostics) } folderList, diags := types.SetValueFrom(ctx, RootFolder{}.getType(), rootFolders) diff --git a/internal/provider/system_status_data_source.go b/internal/provider/system_status_data_source.go index 00f9bc3..25791c4 100644 --- a/internal/provider/system_status_data_source.go +++ b/internal/provider/system_status_data_source.go @@ -211,7 +211,7 @@ func (d *SystemStatusDataSource) Configure(ctx context.Context, req datasource.C func (d *SystemStatusDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get system status current value - response, _, err := d.client.SystemApi.GetSystemStatus(ctx).Execute() + response, _, err := d.client.SystemAPI.GetSystemStatus(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, systemStatusDataSourceName, err)) diff --git a/internal/provider/tag_data_source.go b/internal/provider/tag_data_source.go index afff7cd..2c9334d 100644 --- a/internal/provider/tag_data_source.go +++ b/internal/provider/tag_data_source.go @@ -62,14 +62,18 @@ func (d *TagDataSource) Read(ctx context.Context, req datasource.ReadRequest, re } // Get tags current value - response, _, err := d.client.TagApi.ListTag(ctx).Execute() + response, _, err := d.client.TagAPI.ListTag(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, tagDataSourceName, err)) return } - data.find(data.Label.ValueString(), response, &resp.Diagnostics) + tags := make([]*readarr.TagResource, len(response)) + for i := range response { + tags[i] = &response[i] + } + data.find(data.Label.ValueString(), tags, &resp.Diagnostics) tflog.Trace(ctx, "read "+tagDataSourceName) // Map response body to resource schema attribute resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/tag_resource.go b/internal/provider/tag_resource.go index 7287ea6..ca76db3 100644 --- a/internal/provider/tag_resource.go +++ b/internal/provider/tag_resource.go @@ -100,7 +100,7 @@ func (r *TagResource) Create(ctx context.Context, req resource.CreateRequest, re request := *readarr.NewTagResource() request.SetLabel(tag.Label.ValueString()) - response, _, err := r.client.TagApi.CreateTag(ctx).TagResource(request).Execute() + response, _, err := r.client.TagAPI.CreateTag(ctx).TagResource(request).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Create, tagResourceName, err)) @@ -124,7 +124,7 @@ func (r *TagResource) Read(ctx context.Context, req resource.ReadRequest, resp * } // Get tag current value - response, _, err := r.client.TagApi.GetTagById(ctx, int32(tag.ID.ValueInt64())).Execute() + response, _, err := r.client.TagAPI.GetTagById(ctx, int32(tag.ID.ValueInt64())).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, tagResourceName, err)) @@ -152,7 +152,7 @@ func (r *TagResource) Update(ctx context.Context, req resource.UpdateRequest, re tagResource.SetLabel(tag.Label.ValueString()) tagResource.SetId(int32(tag.ID.ValueInt64())) - response, _, err := r.client.TagApi.UpdateTag(ctx, fmt.Sprint(tagResource.GetId())).TagResource(tagResource).Execute() + response, _, err := r.client.TagAPI.UpdateTag(ctx, fmt.Sprint(tagResource.GetId())).TagResource(tagResource).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Update, tagResourceName, err)) @@ -175,7 +175,7 @@ func (r *TagResource) Delete(ctx context.Context, req resource.DeleteRequest, re } // Delete tag current value - _, err := r.client.TagApi.DeleteTag(ctx, int32(ID)).Execute() + _, err := r.client.TagAPI.DeleteTag(ctx, int32(ID)).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Delete, tagResourceName, err)) diff --git a/internal/provider/tags_data_source.go b/internal/provider/tags_data_source.go index 8642b20..58783a4 100644 --- a/internal/provider/tags_data_source.go +++ b/internal/provider/tags_data_source.go @@ -73,7 +73,7 @@ func (d *TagsDataSource) Configure(ctx context.Context, req datasource.Configure func (d *TagsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, resp *datasource.ReadResponse) { // Get tags current value - response, _, err := d.client.TagApi.ListTag(ctx).Execute() + response, _, err := d.client.TagAPI.ListTag(ctx).Execute() if err != nil { resp.Diagnostics.AddError(helpers.ClientError, helpers.ParseClientError(helpers.Read, tagsDataSourceName, err)) @@ -84,7 +84,7 @@ func (d *TagsDataSource) Read(ctx context.Context, _ datasource.ReadRequest, res // Map response body to resource schema attribute tags := make([]Tag, len(response)) for i, t := range response { - tags[i].write(t) + tags[i].write(&t) } tagList, diags := types.SetValueFrom(ctx, Tag{}.getType(), tags) From 2d44b5869dad2897a4f77c0497419dad991b6c4f Mon Sep 17 00:00:00 2001 From: Sean O'Brien Date: Tue, 4 Feb 2025 16:41:49 -0600 Subject: [PATCH 2/2] support for readarr authentication settings --- internal/provider/host_resource.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/provider/host_resource.go b/internal/provider/host_resource.go index b71ca46..e4578da 100644 --- a/internal/provider/host_resource.go +++ b/internal/provider/host_resource.go @@ -6,6 +6,7 @@ import ( "github.com/devopsarr/readarr-go/readarr" "github.com/devopsarr/terraform-provider-readarr/internal/helpers" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -16,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -107,6 +109,7 @@ type AuthConfig struct { Username types.String `tfsdk:"username"` Password types.String `tfsdk:"password"` EncryptedPassword types.String `tfsdk:"encrypted_password"` + Required types.String `tfsdk:"required"` } func (a AuthConfig) getType() attr.Type { @@ -116,6 +119,7 @@ func (a AuthConfig) getType() attr.Type { "username": types.StringType, "password": types.StringType, "encrypted_password": types.StringType, + "required": types.StringType, }) } @@ -300,6 +304,15 @@ func (r *HostResource) Schema(_ context.Context, _ resource.SchemaRequest, resp Computed: true, Sensitive: true, }, + "required": schema.StringAttribute{ + MarkdownDescription: "Required for everyone or disabled for local addresses.", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf("disabledForLocalAddresses", "enabled"), + }, + Default: stringdefault.StaticString("disabledForLocalAddresses"), + }, }, }, "ssl": schema.SingleNestedAttribute{ @@ -544,6 +557,7 @@ func (a *AuthConfig) write(host *readarr.HostConfigResource) { a.Method = types.StringValue(string(host.GetAuthenticationMethod())) a.Username = types.StringValue(host.GetUsername()) a.EncryptedPassword = types.StringValue(host.GetPassword()) + a.Required = types.StringValue(string(host.GetAuthenticationRequired())) } func (s *SSLConfig) write(host *readarr.HostConfigResource) { @@ -625,7 +639,9 @@ func (b *BackupConfig) read(host *readarr.HostConfigResource) { func (a *AuthConfig) read(host *readarr.HostConfigResource) { host.SetAuthenticationMethod(readarr.AuthenticationType(a.Method.ValueString())) host.SetUsername(a.Username.ValueString()) + host.SetAuthenticationRequired(readarr.AuthenticationRequiredType(a.Required.ValueString())) host.SetPassword(a.Password.ValueString()) + host.SetPasswordConfirmation(a.Password.ValueString()) } func (s *SSLConfig) read(host *readarr.HostConfigResource) {