// Code generated by internal/generate/tags/main.go; DO NOT EDIT.
package transfer

import (
	"context"
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/transfer"
	"github.com/aws/aws-sdk-go/service/transfer/transferiface"
	tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
)

// UpdateTagsNoIgnoreSystem updates transfer service tags.
// The identifier is typically the Amazon Resource Name (ARN), although
// it may also be a different identifier depending on the service.
func UpdateTagsNoIgnoreSystem(conn transferiface.TransferAPI, identifier string, oldTags interface{}, newTags interface{}) error {
	return UpdateTagsNoIgnoreSystemWithContext(context.Background(), conn, identifier, oldTags, newTags)
}
func UpdateTagsNoIgnoreSystemWithContext(ctx context.Context, conn transferiface.TransferAPI, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error {
	oldTags := tftags.New(oldTagsMap)
	newTags := tftags.New(newTagsMap)

	if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 {
		input := &transfer.UntagResourceInput{
			Arn:     aws.String(identifier),
			TagKeys: aws.StringSlice(removedTags.Keys()),
		}

		_, err := conn.UntagResourceWithContext(ctx, input)

		if err != nil {
			return fmt.Errorf("untagging resource (%s): %w", identifier, err)
		}
	}

	if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 {
		input := &transfer.TagResourceInput{
			Arn:  aws.String(identifier),
			Tags: Tags(updatedTags),
		}

		_, err := conn.TagResourceWithContext(ctx, input)

		if err != nil {
			return fmt.Errorf("tagging resource (%s): %w", identifier, err)
		}
	}

	return nil
}
