github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/api/cloudcontroller/ccv3/process.go (about)

     1  package ccv3
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccerror"
     5  	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
     6  )
     7  
     8  type Process struct {
     9  	GUID       string `json:"guid"`
    10  	Type       string `json:"type"`
    11  	MemoryInMB int    `json:"memory_in_mb"`
    12  }
    13  
    14  // GetApplicationProcesses lists processes for a given app
    15  func (client *Client) GetApplicationProcesses(appGUID string) ([]Process, Warnings, error) {
    16  	request, err := client.newHTTPRequest(requestOptions{
    17  		RequestName: internal.GetAppProcessesRequest,
    18  		URIParams:   map[string]string{"guid": appGUID},
    19  	})
    20  	if err != nil {
    21  		return nil, nil, err
    22  	}
    23  
    24  	var fullProcessesList []Process
    25  	warnings, err := client.paginate(request, Process{}, func(item interface{}) error {
    26  		if process, ok := item.(Process); ok {
    27  			fullProcessesList = append(fullProcessesList, process)
    28  		} else {
    29  			return ccerror.UnknownObjectInListError{
    30  				Expected:   Process{},
    31  				Unexpected: item,
    32  			}
    33  		}
    34  		return nil
    35  	})
    36  
    37  	return fullProcessesList, warnings, err
    38  }