@Nonnull
    @Override
    public Iterable<AffinityGroup> list(@Nonnull AffinityGroupFilterOptions options) throws InternalException, CloudException {
        AzureMethod method = new AzureMethod(this.provider);
        final AffinityGroupsModel affinityGroupsModel = method.get(AffinityGroupsModel.class, RESOURCE_AFFINITYGROUPS);

        ArrayList<AffinityGroup> affinityGroups = new ArrayList<AffinityGroup>();

        for(AffinityGroupModel affinityGroupModel : affinityGroupsModel.getAffinityGroups())
        {
            //TODO see if name is enough to be used as an id
            AffinityGroup affinityGroup = AffinityGroup.getInstance(affinityGroupModel.getName(),affinityGroupModel.getName(),affinityGroupModel.getDescription(), affinityGroupModel.getLocation(), null);

            if(options != null && options.matches(affinityGroup))
                affinityGroups.add(affinityGroup);
        }

        return affinityGroups;
    }
@ Nonnull @ Override public Iterable < AffinityGroup > list ( @ Nonnull AffinityGroupFilterOptions options ) throws InternalException , CloudException { AzureMethod method = new AzureMethod ( this . provider ) ; final AffinityGroupsModel affinityGroupsModel = method . get ( AffinityGroupsModel . class , RESOURCE_AFFINITYGROUPS ) ; ArrayList < AffinityGroup > affinityGroups = new ArrayList < AffinityGroup > ( ) ; for ( AffinityGroupModel affinityGroupModel : affinityGroupsModel . getAffinityGroups ( ) ) { AffinityGroup affinityGroup = AffinityGroup . getInstance ( affinityGroupModel . getName ( ) , affinityGroupModel . getName ( ) , affinityGroupModel . getDescription ( ) , affinityGroupModel . getLocation ( ) , null ) ; if ( options != null && options . matches ( affinityGroup ) ) affinityGroups . add ( affinityGroup ) ; } return affinityGroups ; }
Lists all of the affinity groups visible to the current account

@param options Filtering options for the list
@return All the affinity groups visible to current account
@throws org.dasein.cloud.InternalException an error occurred within the Dasein Cloud implementation listing the affinity groups
@throws org.dasein.cloud.CloudException    an error occurred within the service provider listing the affinity groups