code: @Override
      public Collection<ScalingGroup> listScalingGroups( AutoScalingGroupFilterOptions options ) throws CloudException, InternalException {
          APITrace.begin(getProvider(), "AutoScaling.listScalingGroups");
          try {
              ProviderContext ctx = getProvider().getContext();
  
              if( ctx == null ) {
                  throw new CloudException("No context has been set for this request");
              }
              ArrayList<ScalingGroup> list = new ArrayList<ScalingGroup>();
  
              Map<String, String> parameters = getAutoScalingParameters(getProvider().getContext(), EC2Method.DESCRIBE_AUTO_SCALING_GROUPS);
              EC2Method method;
              NodeList blocks;
              Document doc;
  
              method = new EC2Method(SERVICE_ID, getProvider(), parameters);
              try {
                  doc = method.invoke();
              }
              catch( EC2Exception e ) {
                  logger.error(e.getSummary());
                  throw new CloudException(e);
              }
              blocks = doc.getElementsByTagName("AutoScalingGroups");
              for( int i = 0; i < blocks.getLength(); i++ ) {
                  NodeList items = blocks.item(i).getChildNodes();
  
                  for( int j = 0; j < items.getLength(); j++ ) {
                      Node item = items.item(j);
  
                      if( item.getNodeName().equals("member") ) {
                          ScalingGroup group = toScalingGroup(ctx, item);
  
                          if( ( group != null && ( options != null && !options.hasCriteria() ) ) || ( group != null && ( options != null && options.hasCriteria() && options.matches(group) ) ) ) {
                              list.add(group);
                          }
                      }
                  }
              }
              return list;
          }
          finally {
              APITrace.end();
          }
      }
docs: Returns filtered list of auto scaling groups.
  
  @param options the filter parameters
  @return filtered list of scaling groups