code: public static String createOdataFilterForTags(String tagName, String tagValue) {
          if (tagName == null) {
              return null;
          } else if (tagValue == null) {
              return String.format("tagname eq '%s'", tagName);
          } else {
              return String.format("tagname eq '%s' and tagvalue eq '%s'", tagName, tagValue);
          }
      }
docs: Creates an Odata filter string that can be used for filtering list results by tags.
  
  @param tagName the name of the tag. If not provided, all resources will be returned.
  @param tagValue the value of the tag. If not provided, only tag name will be filtered.
  @return the Odata filter to pass into list methods