private Set<Shape> getServicesToUpdate(Model model, Set<ShapeId> removedOperations) {
        Set<Shape> result = new HashSet<>();
        for (ServiceShape service : model.getServiceShapesWithTrait(ClientEndpointDiscoveryTrait.class)) {
            ClientEndpointDiscoveryTrait trait = service.expectTrait(ClientEndpointDiscoveryTrait.class);
            if (removedOperations.contains(trait.getOperation())) {
                ServiceShape.Builder builder = service.toBuilder();
                builder.removeTrait(ClientEndpointDiscoveryTrait.ID);
                result.add(builder.build());
            }
        }
        return result;
    }
Removes the endpoint discovery trait from a service if the referenced operation or error are removed.
smithy-aws-traits/src/main/java/software/amazon/smithy/aws/traits/clientendpointdiscovery/CleanClientDiscoveryTraitTransformer.java