github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/api/cloudcontroller/ccv3/sidecar.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  	"code.cloudfoundry.org/cli/types"
     8  )
     9  
    10  type Sidecar struct {
    11  	GUID    string               `json:"guid"`
    12  	Name    string               `json:"name"`
    13  	Command types.FilteredString `json:"command"`
    14  }
    15  
    16  func (client *Client) GetProcessSidecars(processGuid string) ([]Sidecar, Warnings, error) {
    17  	request, err := client.newHTTPRequest(requestOptions{
    18  		RequestName: internal.GetProcessSidecarsRequest,
    19  		URIParams:   map[string]string{"process_guid": processGuid},
    20  	})
    21  	if err != nil {
    22  		return nil, nil, err
    23  	}
    24  
    25  	var fullSidecarList []Sidecar
    26  	warnings, err := client.paginate(request, Sidecar{}, func(item interface{}) error {
    27  		if sidecar, ok := item.(Sidecar); ok {
    28  			fullSidecarList = append(fullSidecarList, sidecar)
    29  		} else {
    30  			return ccerror.UnknownObjectInListError{
    31  				Expected:   Sidecar{},
    32  				Unexpected: item,
    33  			}
    34  		}
    35  		return nil
    36  	})
    37  
    38  	return fullSidecarList, warnings, err
    39  }