private void deleteEach()

in src/main/java/com/awslabs/iot/client/commands/iot/certificates/CleanUpCertificatesCommandHandler.java [31:52]


    private void deleteEach(Certificate certificate) {
        CertificateArn certificateArn = ImmutableCertificateArn.builder().arn(certificate.certificateArn()).build();
        CertificateId certificateId = ImmutableCertificateId.builder().id(certificate.certificateId()).build();

        Stream<ThingName> attachedThings = iotHelper.getAttachedThings(certificateArn);

        if (attachedThings.nonEmpty()) {
            Logger.info(this, String.join("", "Ignoring [", certificateId.getId(), "], it still has things attached to it"));
            return;
        }

        Stream<Policy> attachedPolicies = iotHelper.getAttachedPolicies(certificateArn);

        if (attachedPolicies.nonEmpty()) {
            Logger.info(this, String.join("", "Ignoring [", certificateId.getId(), "], it still has policies attached to it"));
            return;
        }

        Logger.info(this, String.join("", "Deleting [", certificateId.getId(), "]"));

        iotHelper.delete(certificateArn);
    }