github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/resources/quota_resource.go (about)

     1  package resources
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"code.cloudfoundry.org/cli/types"
     7  )
     8  
     9  type Quota struct {
    10  	// GUID is the unique ID of the organization quota.
    11  	GUID string `json:"guid,omitempty"`
    12  	// Name is the name of the organization quota
    13  	Name string `json:"name"`
    14  	// Apps contain the various limits that are associated with applications
    15  	Apps AppLimit `json:"apps"`
    16  	// Services contain the various limits that are associated with services
    17  	Services ServiceLimit `json:"services"`
    18  	// Routes contain the various limits that are associated with routes
    19  	Routes RouteLimit `json:"routes"`
    20  }
    21  
    22  type AppLimit struct {
    23  	TotalMemory       *types.NullInt `json:"total_memory_in_mb,omitempty"`
    24  	InstanceMemory    *types.NullInt `json:"per_process_memory_in_mb,omitempty"`
    25  	TotalAppInstances *types.NullInt `json:"total_instances,omitempty"`
    26  }
    27  
    28  func (al *AppLimit) UnmarshalJSON(rawJSON []byte) error {
    29  	type Alias AppLimit
    30  
    31  	var aux Alias
    32  	err := json.Unmarshal(rawJSON, &aux)
    33  	if err != nil {
    34  		return err
    35  	}
    36  
    37  	*al = AppLimit(aux)
    38  
    39  	if al.TotalMemory == nil {
    40  		al.TotalMemory = &types.NullInt{
    41  			IsSet: false,
    42  			Value: 0,
    43  		}
    44  	}
    45  
    46  	if al.InstanceMemory == nil {
    47  		al.InstanceMemory = &types.NullInt{
    48  			IsSet: false,
    49  			Value: 0,
    50  		}
    51  	}
    52  
    53  	if al.TotalAppInstances == nil {
    54  		al.TotalAppInstances = &types.NullInt{
    55  			IsSet: false,
    56  			Value: 0,
    57  		}
    58  	}
    59  
    60  	return nil
    61  }
    62  
    63  type ServiceLimit struct {
    64  	TotalServiceInstances *types.NullInt `json:"total_service_instances,omitempty"`
    65  	PaidServicePlans      *bool          `json:"paid_services_allowed,omitempty"`
    66  }
    67  
    68  func (sl *ServiceLimit) UnmarshalJSON(rawJSON []byte) error {
    69  	type Alias ServiceLimit
    70  
    71  	var aux Alias
    72  	err := json.Unmarshal(rawJSON, &aux)
    73  	if err != nil {
    74  		return err
    75  	}
    76  
    77  	*sl = ServiceLimit(aux)
    78  
    79  	if sl.TotalServiceInstances == nil {
    80  		sl.TotalServiceInstances = &types.NullInt{
    81  			IsSet: false,
    82  			Value: 0,
    83  		}
    84  	}
    85  
    86  	return nil
    87  }
    88  
    89  type RouteLimit struct {
    90  	TotalRoutes        *types.NullInt `json:"total_routes,omitempty"`
    91  	TotalReservedPorts *types.NullInt `json:"total_reserved_ports,omitempty"`
    92  }
    93  
    94  func (sl *RouteLimit) UnmarshalJSON(rawJSON []byte) error {
    95  	type Alias RouteLimit
    96  
    97  	var aux Alias
    98  	err := json.Unmarshal(rawJSON, &aux)
    99  	if err != nil {
   100  		return err
   101  	}
   102  
   103  	*sl = RouteLimit(aux)
   104  
   105  	if sl.TotalRoutes == nil {
   106  		sl.TotalRoutes = &types.NullInt{
   107  			IsSet: false,
   108  			Value: 0,
   109  		}
   110  	}
   111  
   112  	if sl.TotalReservedPorts == nil {
   113  		sl.TotalReservedPorts = &types.NullInt{
   114  			IsSet: false,
   115  			Value: 0,
   116  		}
   117  	}
   118  
   119  	return nil
   120  }