github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/resources/space_quotas.go (about)

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