github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/resources/quotas.go (about)

     1  package resources
     2  
     3  import "code.cloudfoundry.org/cli/cf/models"
     4  
     5  type PaginatedQuotaResources struct {
     6  	Resources []QuotaResource
     7  }
     8  
     9  type QuotaResource struct {
    10  	Resource
    11  	Entity models.QuotaResponse
    12  }
    13  
    14  func (resource QuotaResource) ToFields() models.QuotaFields {
    15  	appInstanceLimit := UnlimitedAppInstances
    16  	if resource.Entity.AppInstanceLimit != "" {
    17  		i, err := resource.Entity.AppInstanceLimit.Int64()
    18  		if err == nil {
    19  			appInstanceLimit = int(i)
    20  		}
    21  	}
    22  
    23  	return models.QuotaFields{
    24  		GUID:                    resource.Metadata.GUID,
    25  		Name:                    resource.Entity.Name,
    26  		MemoryLimit:             resource.Entity.MemoryLimit,
    27  		InstanceMemoryLimit:     resource.Entity.InstanceMemoryLimit,
    28  		RoutesLimit:             resource.Entity.RoutesLimit,
    29  		ServicesLimit:           resource.Entity.ServicesLimit,
    30  		NonBasicServicesAllowed: resource.Entity.NonBasicServicesAllowed,
    31  		AppInstanceLimit:        appInstanceLimit,
    32  		ReservedRoutePorts:      resource.Entity.ReservedRoutePorts,
    33  	}
    34  }