private ProgressEvent updateTags()

in aws-networkfirewall-rulegroup/src/main/java/software/amazon/networkfirewall/rulegroup/UpdateHandler.java [147:176]


    private ProgressEvent<ResourceModel, CallbackContext> updateTags(ProgressEvent<ResourceModel, CallbackContext> progress) {
        final TagUtils tagUtils = new TagUtils(previousStateModel.getTags(), desiredStateModel.getTags(),
                handlerRequest.getPreviousResourceTags(), handlerRequest.getDesiredResourceTags());

        // Untag resource: get tags to remove from firewall resource
        if (tagUtils.tagsToRemove().size() > 0) {
            progress = proxy.initiate("RuleGroup::Update-UntagResource", proxyClient, progress.getResourceModel(), callbackContext)
                    .translateToServiceRequest(model ->
                            Translator.translateToUntagRequest(model, tagUtils.tagsToRemove().keySet()))
                    .makeServiceCall((request, client) ->
                            client.injectCredentialsAndInvokeV2(request, client.client()::untagResource))
                    .progress();

            if (progress.isFailed()) {
                return progress;
            }
        }

        // Tag resource: add tags that are added newly and update tags for which the value has been updated
        if (tagUtils.tagsToAddOrUpdate().size() > 0) {
            progress = proxy.initiate("RuleGroup::Update-TagResource", proxyClient, progress.getResourceModel(), callbackContext)
                    .translateToServiceRequest(model ->
                            Translator.translateToTagRequest(model, tagUtils.tagsToAddOrUpdate()))
                    .makeServiceCall((request, client) ->
                            client.injectCredentialsAndInvokeV2(request, client.client()::tagResource))
                    .progress();
        }

        return progress;
    }