repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
cloudfoundry/cli
integration/helpers/matchers.go
SayPath
func SayPath(format string, path string) types.GomegaMatcher { theRealDir, err := filepath.EvalSymlinks(filepath.Dir(path)) Expect(err).ToNot(HaveOccurred()) theRealPath := filepath.Join(theRealDir, filepath.Base(path)) if runtime.GOOS == "windows" { expected := "(?i)" + format expected = fmt.Sprintf(expected, regexp.QuoteMeta(path)) return gbytes.Say(expected) } return gbytes.Say(format, theRealPath) }
go
func SayPath(format string, path string) types.GomegaMatcher { theRealDir, err := filepath.EvalSymlinks(filepath.Dir(path)) Expect(err).ToNot(HaveOccurred()) theRealPath := filepath.Join(theRealDir, filepath.Base(path)) if runtime.GOOS == "windows" { expected := "(?i)" + format expected = fmt.Sprintf(expected, regexp.QuoteMeta(path)) return gbytes.Say(expected) } return gbytes.Say(format, theRealPath) }
[ "func", "SayPath", "(", "format", "string", ",", "path", "string", ")", "types", ".", "GomegaMatcher", "{", "theRealDir", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "filepath", ".", "Dir", "(", "path", ")", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "theRealPath", ":=", "filepath", ".", "Join", "(", "theRealDir", ",", "filepath", ".", "Base", "(", "path", ")", ")", "\n\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "expected", ":=", "\"", "\"", "+", "format", "\n", "expected", "=", "fmt", ".", "Sprintf", "(", "expected", ",", "regexp", ".", "QuoteMeta", "(", "path", ")", ")", "\n", "return", "gbytes", ".", "Say", "(", "expected", ")", "\n", "}", "\n", "return", "gbytes", ".", "Say", "(", "format", ",", "theRealPath", ")", "\n", "}" ]
// SayPath is used to assert that a path is printed. On Windows, it uses a // case-insensitive match and escapes the path. On non-Windows, it evaluates // the base directory of the path for symlniks.
[ "SayPath", "is", "used", "to", "assert", "that", "a", "path", "is", "printed", ".", "On", "Windows", "it", "uses", "a", "case", "-", "insensitive", "match", "and", "escapes", "the", "path", ".", "On", "non", "-", "Windows", "it", "evaluates", "the", "base", "directory", "of", "the", "path", "for", "symlniks", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/matchers.go#L19-L30
train
cloudfoundry/cli
api/cloudcontroller/ccv2/buildpack.go
CreateBuildpack
func (client *Client) CreateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) { body, err := json.Marshal(buildpack) if err != nil { return Buildpack{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildpackRequest, Body: bytes.NewReader(body), }) if err != nil { return Buildpack{}, nil, err } var createdBuildpack Buildpack response := cloudcontroller.Response{ DecodeJSONResponseInto: &createdBuildpack, } err = client.connection.Make(request, &response) return createdBuildpack, response.Warnings, err }
go
func (client *Client) CreateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) { body, err := json.Marshal(buildpack) if err != nil { return Buildpack{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildpackRequest, Body: bytes.NewReader(body), }) if err != nil { return Buildpack{}, nil, err } var createdBuildpack Buildpack response := cloudcontroller.Response{ DecodeJSONResponseInto: &createdBuildpack, } err = client.connection.Make(request, &response) return createdBuildpack, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateBuildpack", "(", "buildpack", "Buildpack", ")", "(", "Buildpack", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "buildpack", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Buildpack", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostBuildpackRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Buildpack", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "createdBuildpack", "Buildpack", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "createdBuildpack", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "createdBuildpack", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateBuildpack creates a new buildpack.
[ "CreateBuildpack", "creates", "a", "new", "buildpack", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L76-L97
train
cloudfoundry/cli
api/cloudcontroller/ccv2/buildpack.go
GetBuildpacks
func (client *Client) GetBuildpacks(filters ...Filter) ([]Buildpack, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildpacksRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var buildpacks []Buildpack warnings, err := client.paginate(request, Buildpack{}, func(item interface{}) error { if buildpack, ok := item.(Buildpack); ok { buildpacks = append(buildpacks, buildpack) } else { return ccerror.UnknownObjectInListError{ Expected: Buildpack{}, Unexpected: item, } } return nil }) return buildpacks, warnings, err }
go
func (client *Client) GetBuildpacks(filters ...Filter) ([]Buildpack, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildpacksRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var buildpacks []Buildpack warnings, err := client.paginate(request, Buildpack{}, func(item interface{}) error { if buildpack, ok := item.(Buildpack); ok { buildpacks = append(buildpacks, buildpack) } else { return ccerror.UnknownObjectInListError{ Expected: Buildpack{}, Unexpected: item, } } return nil }) return buildpacks, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetBuildpacks", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Buildpack", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetBuildpacksRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "buildpacks", "[", "]", "Buildpack", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Buildpack", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "buildpack", ",", "ok", ":=", "item", ".", "(", "Buildpack", ")", ";", "ok", "{", "buildpacks", "=", "append", "(", "buildpacks", ",", "buildpack", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Buildpack", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "buildpacks", ",", "warnings", ",", "err", "\n", "}" ]
// GetBuildpacks searches for a buildpack with the given name and returns it if it exists.
[ "GetBuildpacks", "searches", "for", "a", "buildpack", "with", "the", "given", "name", "and", "returns", "it", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L100-L124
train
cloudfoundry/cli
api/cloudcontroller/ccv2/buildpack.go
UploadBuildpack
func (client *Client) UploadBuildpack(buildpackGUID string, buildpackPath string, buildpack io.Reader, buildpackLength int64) (Warnings, error) { contentLength, err := buildpacks.CalculateRequestSize(buildpackLength, buildpackPath, "buildpack") if err != nil { return nil, err } contentType, body, writeErrors := buildpacks.CreateMultipartBodyAndHeader(buildpack, buildpackPath, "buildpack") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutBuildpackBitsRequest, URIParams: Params{"buildpack_guid": buildpackGUID}, Body: body, }) if err != nil { return nil, err } request.Header.Set("Content-Type", contentType) request.ContentLength = contentLength _, warnings, err := client.uploadBuildpackAsynchronously(request, writeErrors) if err != nil { return warnings, err } return warnings, nil }
go
func (client *Client) UploadBuildpack(buildpackGUID string, buildpackPath string, buildpack io.Reader, buildpackLength int64) (Warnings, error) { contentLength, err := buildpacks.CalculateRequestSize(buildpackLength, buildpackPath, "buildpack") if err != nil { return nil, err } contentType, body, writeErrors := buildpacks.CreateMultipartBodyAndHeader(buildpack, buildpackPath, "buildpack") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutBuildpackBitsRequest, URIParams: Params{"buildpack_guid": buildpackGUID}, Body: body, }) if err != nil { return nil, err } request.Header.Set("Content-Type", contentType) request.ContentLength = contentLength _, warnings, err := client.uploadBuildpackAsynchronously(request, writeErrors) if err != nil { return warnings, err } return warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "UploadBuildpack", "(", "buildpackGUID", "string", ",", "buildpackPath", "string", ",", "buildpack", "io", ".", "Reader", ",", "buildpackLength", "int64", ")", "(", "Warnings", ",", "error", ")", "{", "contentLength", ",", "err", ":=", "buildpacks", ".", "CalculateRequestSize", "(", "buildpackLength", ",", "buildpackPath", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "contentType", ",", "body", ",", "writeErrors", ":=", "buildpacks", ".", "CreateMultipartBodyAndHeader", "(", "buildpack", ",", "buildpackPath", ",", "\"", "\"", ")", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutBuildpackBitsRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "buildpackGUID", "}", ",", "Body", ":", "body", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "contentType", ")", "\n", "request", ".", "ContentLength", "=", "contentLength", "\n\n", "_", ",", "warnings", ",", "err", ":=", "client", ".", "uploadBuildpackAsynchronously", "(", "request", ",", "writeErrors", ")", "\n", "if", "err", "!=", "nil", "{", "return", "warnings", ",", "err", "\n", "}", "\n", "return", "warnings", ",", "nil", "\n", "}" ]
// UploadBuildpack uploads the contents of a buildpack zip to the server.
[ "UploadBuildpack", "uploads", "the", "contents", "of", "a", "buildpack", "zip", "to", "the", "server", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L158-L185
train
cloudfoundry/cli
util/sorting/alphabetic.go
LessIgnoreCase
func LessIgnoreCase(first string, second string) bool { iRunes := []rune(first) jRunes := []rune(second) max := len(iRunes) if max > len(jRunes) { max = len(jRunes) } for idx := 0; idx < max; idx++ { ir := iRunes[idx] jr := jRunes[idx] lir := unicode.ToLower(ir) ljr := unicode.ToLower(jr) if lir == ljr { continue } return lir < ljr } return false }
go
func LessIgnoreCase(first string, second string) bool { iRunes := []rune(first) jRunes := []rune(second) max := len(iRunes) if max > len(jRunes) { max = len(jRunes) } for idx := 0; idx < max; idx++ { ir := iRunes[idx] jr := jRunes[idx] lir := unicode.ToLower(ir) ljr := unicode.ToLower(jr) if lir == ljr { continue } return lir < ljr } return false }
[ "func", "LessIgnoreCase", "(", "first", "string", ",", "second", "string", ")", "bool", "{", "iRunes", ":=", "[", "]", "rune", "(", "first", ")", "\n", "jRunes", ":=", "[", "]", "rune", "(", "second", ")", "\n\n", "max", ":=", "len", "(", "iRunes", ")", "\n", "if", "max", ">", "len", "(", "jRunes", ")", "{", "max", "=", "len", "(", "jRunes", ")", "\n", "}", "\n\n", "for", "idx", ":=", "0", ";", "idx", "<", "max", ";", "idx", "++", "{", "ir", ":=", "iRunes", "[", "idx", "]", "\n", "jr", ":=", "jRunes", "[", "idx", "]", "\n\n", "lir", ":=", "unicode", ".", "ToLower", "(", "ir", ")", "\n", "ljr", ":=", "unicode", ".", "ToLower", "(", "jr", ")", "\n\n", "if", "lir", "==", "ljr", "{", "continue", "\n", "}", "\n\n", "return", "lir", "<", "ljr", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// LessIgnoreCase returns true if first is alphabetically less than second.
[ "LessIgnoreCase", "returns", "true", "if", "first", "is", "alphabetically", "less", "than", "second", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/sorting/alphabetic.go#L10-L34
train
cloudfoundry/cli
actor/v2action/security_group.go
GetSpaceRunningSecurityGroupsBySpace
func (actor Actor) GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) { ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceSecurityGroups(spaceGUID) return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err) }
go
func (actor Actor) GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) { ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceSecurityGroups(spaceGUID) return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err) }
[ "func", "(", "actor", "Actor", ")", "GetSpaceRunningSecurityGroupsBySpace", "(", "spaceGUID", "string", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "ccv2SecurityGroups", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceSecurityGroups", "(", "spaceGUID", ")", "\n", "return", "processSecurityGroups", "(", "spaceGUID", ",", "ccv2SecurityGroups", ",", "Warnings", "(", "warnings", ")", ",", "err", ")", "\n", "}" ]
// GetSpaceRunningSecurityGroupsBySpace returns a list of all security groups // bound to this space in the 'running' lifecycle phase.
[ "GetSpaceRunningSecurityGroupsBySpace", "returns", "a", "list", "of", "all", "security", "groups", "bound", "to", "this", "space", "in", "the", "running", "lifecycle", "phase", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/security_group.go#L236-L239
train
cloudfoundry/cli
actor/v2action/security_group.go
GetSpaceStagingSecurityGroupsBySpace
func (actor Actor) GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) { ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceStagingSecurityGroups(spaceGUID) return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err) }
go
func (actor Actor) GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) { ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceStagingSecurityGroups(spaceGUID) return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err) }
[ "func", "(", "actor", "Actor", ")", "GetSpaceStagingSecurityGroupsBySpace", "(", "spaceGUID", "string", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "ccv2SecurityGroups", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceStagingSecurityGroups", "(", "spaceGUID", ")", "\n", "return", "processSecurityGroups", "(", "spaceGUID", ",", "ccv2SecurityGroups", ",", "Warnings", "(", "warnings", ")", ",", "err", ")", "\n", "}" ]
// GetSpaceStagingSecurityGroupsBySpace returns a list of all security groups // bound to this space in the 'staging' lifecycle phase. with an optional
[ "GetSpaceStagingSecurityGroupsBySpace", "returns", "a", "list", "of", "all", "security", "groups", "bound", "to", "this", "space", "in", "the", "staging", "lifecycle", "phase", ".", "with", "an", "optional" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/security_group.go#L243-L246
train
cloudfoundry/cli
cf/util/downloader/file_download.go
DownloadFile
func (d *downloader) DownloadFile(url string) (int64, string, error) { c := http.Client{ CheckRedirect: func(r *http.Request, via []*http.Request) error { r.URL.Opaque = r.URL.Path //some redirect return '/' as url if strings.Trim(r.URL.Opaque, "/") != "" { url = r.URL.Opaque } return nil }, } r, err := c.Get(url) if err != nil { return 0, "", err } defer r.Body.Close() if r.StatusCode == 200 { d.filename = getFilenameFromHeader(r.Header.Get("Content-Disposition")) if d.filename == "" { d.filename = getFilenameFromURL(url) } f, err := os.Create(filepath.Join(d.saveDir, d.filename)) if err != nil { return 0, "", err } defer f.Close() size, err := io.Copy(f, r.Body) if err != nil { return 0, "", err } d.downloaded = true return size, d.filename, nil } return 0, "", fmt.Errorf("Error downloading file from %s", url) }
go
func (d *downloader) DownloadFile(url string) (int64, string, error) { c := http.Client{ CheckRedirect: func(r *http.Request, via []*http.Request) error { r.URL.Opaque = r.URL.Path //some redirect return '/' as url if strings.Trim(r.URL.Opaque, "/") != "" { url = r.URL.Opaque } return nil }, } r, err := c.Get(url) if err != nil { return 0, "", err } defer r.Body.Close() if r.StatusCode == 200 { d.filename = getFilenameFromHeader(r.Header.Get("Content-Disposition")) if d.filename == "" { d.filename = getFilenameFromURL(url) } f, err := os.Create(filepath.Join(d.saveDir, d.filename)) if err != nil { return 0, "", err } defer f.Close() size, err := io.Copy(f, r.Body) if err != nil { return 0, "", err } d.downloaded = true return size, d.filename, nil } return 0, "", fmt.Errorf("Error downloading file from %s", url) }
[ "func", "(", "d", "*", "downloader", ")", "DownloadFile", "(", "url", "string", ")", "(", "int64", ",", "string", ",", "error", ")", "{", "c", ":=", "http", ".", "Client", "{", "CheckRedirect", ":", "func", "(", "r", "*", "http", ".", "Request", ",", "via", "[", "]", "*", "http", ".", "Request", ")", "error", "{", "r", ".", "URL", ".", "Opaque", "=", "r", ".", "URL", ".", "Path", "\n\n", "//some redirect return '/' as url", "if", "strings", ".", "Trim", "(", "r", ".", "URL", ".", "Opaque", ",", "\"", "\"", ")", "!=", "\"", "\"", "{", "url", "=", "r", ".", "URL", ".", "Opaque", "\n", "}", "\n\n", "return", "nil", "\n", "}", ",", "}", "\n\n", "r", ",", "err", ":=", "c", ".", "Get", "(", "url", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "r", ".", "Body", ".", "Close", "(", ")", "\n\n", "if", "r", ".", "StatusCode", "==", "200", "{", "d", ".", "filename", "=", "getFilenameFromHeader", "(", "r", ".", "Header", ".", "Get", "(", "\"", "\"", ")", ")", "\n\n", "if", "d", ".", "filename", "==", "\"", "\"", "{", "d", ".", "filename", "=", "getFilenameFromURL", "(", "url", ")", "\n", "}", "\n\n", "f", ",", "err", ":=", "os", ".", "Create", "(", "filepath", ".", "Join", "(", "d", ".", "saveDir", ",", "d", ".", "filename", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "\"", "\"", ",", "err", "\n", "}", "\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "size", ",", "err", ":=", "io", ".", "Copy", "(", "f", ",", "r", ".", "Body", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "d", ".", "downloaded", "=", "true", "\n", "return", "size", ",", "d", ".", "filename", ",", "nil", "\n\n", "}", "\n", "return", "0", ",", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "url", ")", "\n", "}" ]
//this func returns byte written, filename and error
[ "this", "func", "returns", "byte", "written", "filename", "and", "error" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/downloader/file_download.go#L32-L76
train
cloudfoundry/cli
api/cloudcontroller/ccv2/paginated_resources.go
Resources
func (pr PaginatedResources) Resources() ([]interface{}, error) { slicePtr := reflect.New(reflect.SliceOf(pr.resourceType)) err := json.Unmarshal([]byte(pr.ResourcesBytes), slicePtr.Interface()) slice := reflect.Indirect(slicePtr) contents := make([]interface{}, 0, slice.Len()) for i := 0; i < slice.Len(); i++ { contents = append(contents, slice.Index(i).Interface()) } return contents, err }
go
func (pr PaginatedResources) Resources() ([]interface{}, error) { slicePtr := reflect.New(reflect.SliceOf(pr.resourceType)) err := json.Unmarshal([]byte(pr.ResourcesBytes), slicePtr.Interface()) slice := reflect.Indirect(slicePtr) contents := make([]interface{}, 0, slice.Len()) for i := 0; i < slice.Len(); i++ { contents = append(contents, slice.Index(i).Interface()) } return contents, err }
[ "func", "(", "pr", "PaginatedResources", ")", "Resources", "(", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{", "slicePtr", ":=", "reflect", ".", "New", "(", "reflect", ".", "SliceOf", "(", "pr", ".", "resourceType", ")", ")", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "pr", ".", "ResourcesBytes", ")", ",", "slicePtr", ".", "Interface", "(", ")", ")", "\n", "slice", ":=", "reflect", ".", "Indirect", "(", "slicePtr", ")", "\n\n", "contents", ":=", "make", "(", "[", "]", "interface", "{", "}", ",", "0", ",", "slice", ".", "Len", "(", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "slice", ".", "Len", "(", ")", ";", "i", "++", "{", "contents", "=", "append", "(", "contents", ",", "slice", ".", "Index", "(", "i", ")", ".", "Interface", "(", ")", ")", "\n", "}", "\n", "return", "contents", ",", "err", "\n", "}" ]
// Resources unmarshals JSON representing a page of resources and returns a // slice of the given resource type.
[ "Resources", "unmarshals", "JSON", "representing", "a", "page", "of", "resources", "and", "returns", "a", "slice", "of", "the", "given", "resource", "type", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/paginated_resources.go#L29-L39
train
cloudfoundry/cli
actor/v2action/space.go
GetSpaceByOrganizationAndName
func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) { ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{spaceName}, }, ccv2.Filter{ Type: constant.OrganizationGUIDFilter, Operator: constant.EqualOperator, Values: []string{orgGUID}, }, ) if err != nil { return Space{}, Warnings(warnings), err } if len(ccv2Spaces) == 0 { return Space{}, Warnings(warnings), actionerror.SpaceNotFoundError{Name: spaceName} } if len(ccv2Spaces) > 1 { return Space{}, Warnings(warnings), actionerror.MultipleSpacesFoundError{OrgGUID: orgGUID, Name: spaceName} } return Space(ccv2Spaces[0]), Warnings(warnings), nil }
go
func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) { ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{spaceName}, }, ccv2.Filter{ Type: constant.OrganizationGUIDFilter, Operator: constant.EqualOperator, Values: []string{orgGUID}, }, ) if err != nil { return Space{}, Warnings(warnings), err } if len(ccv2Spaces) == 0 { return Space{}, Warnings(warnings), actionerror.SpaceNotFoundError{Name: spaceName} } if len(ccv2Spaces) > 1 { return Space{}, Warnings(warnings), actionerror.MultipleSpacesFoundError{OrgGUID: orgGUID, Name: spaceName} } return Space(ccv2Spaces[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetSpaceByOrganizationAndName", "(", "orgGUID", "string", ",", "spaceName", "string", ")", "(", "Space", ",", "Warnings", ",", "error", ")", "{", "ccv2Spaces", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaces", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "spaceName", "}", ",", "}", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "OrganizationGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "orgGUID", "}", ",", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Space", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "ccv2Spaces", ")", "==", "0", "{", "return", "Space", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "SpaceNotFoundError", "{", "Name", ":", "spaceName", "}", "\n", "}", "\n\n", "if", "len", "(", "ccv2Spaces", ")", ">", "1", "{", "return", "Space", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "MultipleSpacesFoundError", "{", "OrgGUID", ":", "orgGUID", ",", "Name", ":", "spaceName", "}", "\n", "}", "\n\n", "return", "Space", "(", "ccv2Spaces", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetSpaceByOrganizationAndName returns an Space based on the org and name.
[ "GetSpaceByOrganizationAndName", "returns", "an", "Space", "based", "on", "the", "org", "and", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L101-L127
train
cloudfoundry/cli
actor/v2action/space.go
GrantSpaceManagerByUsername
func (actor Actor) GrantSpaceManagerByUsername(orgGUID string, spaceGUID string, username string) (Warnings, error) { if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) { return actor.grantSpaceManagerByClientCredentials(orgGUID, spaceGUID, username) } return actor.grantSpaceManagerByUsername(orgGUID, spaceGUID, username) }
go
func (actor Actor) GrantSpaceManagerByUsername(orgGUID string, spaceGUID string, username string) (Warnings, error) { if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) { return actor.grantSpaceManagerByClientCredentials(orgGUID, spaceGUID, username) } return actor.grantSpaceManagerByUsername(orgGUID, spaceGUID, username) }
[ "func", "(", "actor", "Actor", ")", "GrantSpaceManagerByUsername", "(", "orgGUID", "string", ",", "spaceGUID", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "if", "actor", ".", "Config", ".", "UAAGrantType", "(", ")", "==", "string", "(", "uaaconst", ".", "GrantTypeClientCredentials", ")", "{", "return", "actor", ".", "grantSpaceManagerByClientCredentials", "(", "orgGUID", ",", "spaceGUID", ",", "username", ")", "\n", "}", "\n\n", "return", "actor", ".", "grantSpaceManagerByUsername", "(", "orgGUID", ",", "spaceGUID", ",", "username", ")", "\n", "}" ]
// GrantSpaceManagerByUsername makes the provided user a Space Manager in the // space with the provided guid.
[ "GrantSpaceManagerByUsername", "makes", "the", "provided", "user", "a", "Space", "Manager", "in", "the", "space", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L131-L137
train
cloudfoundry/cli
actor/v2action/space.go
GrantSpaceDeveloperByUsername
func (actor Actor) GrantSpaceDeveloperByUsername(spaceGUID string, username string) (Warnings, error) { if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) { warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloper(spaceGUID, username) return Warnings(warnings), err } warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloperByUsername(spaceGUID, username) return Warnings(warnings), err }
go
func (actor Actor) GrantSpaceDeveloperByUsername(spaceGUID string, username string) (Warnings, error) { if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) { warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloper(spaceGUID, username) return Warnings(warnings), err } warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloperByUsername(spaceGUID, username) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GrantSpaceDeveloperByUsername", "(", "spaceGUID", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "if", "actor", ".", "Config", ".", "UAAGrantType", "(", ")", "==", "string", "(", "uaaconst", ".", "GrantTypeClientCredentials", ")", "{", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateSpaceDeveloper", "(", "spaceGUID", ",", "username", ")", "\n\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateSpaceDeveloperByUsername", "(", "spaceGUID", ",", "username", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GrantSpaceDeveloperByUsername makes the provided user a Space Developer in the // space with the provided guid.
[ "GrantSpaceDeveloperByUsername", "makes", "the", "provided", "user", "a", "Space", "Developer", "in", "the", "space", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L170-L179
train
cloudfoundry/cli
actor/v2action/user.go
CreateUser
func (actor Actor) CreateUser(username string, password string, origin string) (User, Warnings, error) { uaaUser, err := actor.UAAClient.CreateUser(username, password, origin) if err != nil { return User{}, nil, err } ccUser, ccWarnings, err := actor.CloudControllerClient.CreateUser(uaaUser.ID) return User(ccUser), Warnings(ccWarnings), err }
go
func (actor Actor) CreateUser(username string, password string, origin string) (User, Warnings, error) { uaaUser, err := actor.UAAClient.CreateUser(username, password, origin) if err != nil { return User{}, nil, err } ccUser, ccWarnings, err := actor.CloudControllerClient.CreateUser(uaaUser.ID) return User(ccUser), Warnings(ccWarnings), err }
[ "func", "(", "actor", "Actor", ")", "CreateUser", "(", "username", "string", ",", "password", "string", ",", "origin", "string", ")", "(", "User", ",", "Warnings", ",", "error", ")", "{", "uaaUser", ",", "err", ":=", "actor", ".", "UAAClient", ".", "CreateUser", "(", "username", ",", "password", ",", "origin", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "ccUser", ",", "ccWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateUser", "(", "uaaUser", ".", "ID", ")", "\n\n", "return", "User", "(", "ccUser", ")", ",", "Warnings", "(", "ccWarnings", ")", ",", "err", "\n", "}" ]
// CreateUser creates a new user in UAA and registers it with cloud controller.
[ "CreateUser", "creates", "a", "new", "user", "in", "UAA", "and", "registers", "it", "with", "cloud", "controller", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/user.go#L9-L18
train
cloudfoundry/cli
command/v6/shared/new_networking_client.go
NewNetworkingClient
func NewNetworkingClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) (*cfnetv1.Client, error) { if apiURL == "" { return nil, translatableerror.CFNetworkingEndpointNotFoundError{} } wrappers := []cfnetv1.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := wrapper.NewUAAAuthentication(uaaClient, config) wrappers = append(wrappers, authWrapper) wrappers = append(wrappers, wrapper.NewRetryRequest(config.RequestRetryCount())) return cfnetv1.NewClient(cfnetv1.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: config.SkipSSLValidation(), URL: apiURL, Wrappers: wrappers, }), nil }
go
func NewNetworkingClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) (*cfnetv1.Client, error) { if apiURL == "" { return nil, translatableerror.CFNetworkingEndpointNotFoundError{} } wrappers := []cfnetv1.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := wrapper.NewUAAAuthentication(uaaClient, config) wrappers = append(wrappers, authWrapper) wrappers = append(wrappers, wrapper.NewRetryRequest(config.RequestRetryCount())) return cfnetv1.NewClient(cfnetv1.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: config.SkipSSLValidation(), URL: apiURL, Wrappers: wrappers, }), nil }
[ "func", "NewNetworkingClient", "(", "apiURL", "string", ",", "config", "command", ".", "Config", ",", "uaaClient", "*", "uaa", ".", "Client", ",", "ui", "command", ".", "UI", ")", "(", "*", "cfnetv1", ".", "Client", ",", "error", ")", "{", "if", "apiURL", "==", "\"", "\"", "{", "return", "nil", ",", "translatableerror", ".", "CFNetworkingEndpointNotFoundError", "{", "}", "\n", "}", "\n\n", "wrappers", ":=", "[", "]", "cfnetv1", ".", "ConnectionWrapper", "{", "}", "\n\n", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n", "if", "verbose", "{", "wrappers", "=", "append", "(", "wrappers", ",", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "wrappers", "=", "append", "(", "wrappers", ",", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "authWrapper", ":=", "wrapper", ".", "NewUAAAuthentication", "(", "uaaClient", ",", "config", ")", "\n", "wrappers", "=", "append", "(", "wrappers", ",", "authWrapper", ")", "\n\n", "wrappers", "=", "append", "(", "wrappers", ",", "wrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "return", "cfnetv1", ".", "NewClient", "(", "cfnetv1", ".", "Config", "{", "AppName", ":", "config", ".", "BinaryName", "(", ")", ",", "AppVersion", ":", "config", ".", "BinaryVersion", "(", ")", ",", "DialTimeout", ":", "config", ".", "DialTimeout", "(", ")", ",", "SkipSSLValidation", ":", "config", ".", "SkipSSLValidation", "(", ")", ",", "URL", ":", "apiURL", ",", "Wrappers", ":", "wrappers", ",", "}", ")", ",", "nil", "\n", "}" ]
// NewNetworkingClient creates a new cfnetworking client.
[ "NewNetworkingClient", "creates", "a", "new", "cfnetworking", "client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_networking_client.go#L12-L40
train
cloudfoundry/cli
actor/v2action/service_plan.go
GetServicePlansForService
func (actor Actor) GetServicePlansForService(serviceName, brokerName string) ([]ServicePlan, Warnings, error) { service, allWarnings, err := actor.GetServiceByNameAndBrokerName(serviceName, brokerName) if err != nil { return []ServicePlan{}, allWarnings, err } servicePlans, warnings, err := actor.CloudControllerClient.GetServicePlans(ccv2.Filter{ Type: constant.ServiceGUIDFilter, Operator: constant.EqualOperator, Values: []string{service.GUID}, }) allWarnings = append(allWarnings, warnings...) if err != nil { return []ServicePlan{}, allWarnings, err } var plansToReturn []ServicePlan for _, plan := range servicePlans { plansToReturn = append(plansToReturn, ServicePlan(plan)) } return plansToReturn, allWarnings, nil }
go
func (actor Actor) GetServicePlansForService(serviceName, brokerName string) ([]ServicePlan, Warnings, error) { service, allWarnings, err := actor.GetServiceByNameAndBrokerName(serviceName, brokerName) if err != nil { return []ServicePlan{}, allWarnings, err } servicePlans, warnings, err := actor.CloudControllerClient.GetServicePlans(ccv2.Filter{ Type: constant.ServiceGUIDFilter, Operator: constant.EqualOperator, Values: []string{service.GUID}, }) allWarnings = append(allWarnings, warnings...) if err != nil { return []ServicePlan{}, allWarnings, err } var plansToReturn []ServicePlan for _, plan := range servicePlans { plansToReturn = append(plansToReturn, ServicePlan(plan)) } return plansToReturn, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetServicePlansForService", "(", "serviceName", ",", "brokerName", "string", ")", "(", "[", "]", "ServicePlan", ",", "Warnings", ",", "error", ")", "{", "service", ",", "allWarnings", ",", "err", ":=", "actor", ".", "GetServiceByNameAndBrokerName", "(", "serviceName", ",", "brokerName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "ServicePlan", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "servicePlans", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServicePlans", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "ServiceGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "service", ".", "GUID", "}", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "ServicePlan", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "var", "plansToReturn", "[", "]", "ServicePlan", "\n", "for", "_", ",", "plan", ":=", "range", "servicePlans", "{", "plansToReturn", "=", "append", "(", "plansToReturn", ",", "ServicePlan", "(", "plan", ")", ")", "\n", "}", "\n\n", "return", "plansToReturn", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetServicePlansForService returns a list of plans associated with the service and the broker if provided
[ "GetServicePlansForService", "returns", "a", "list", "of", "plans", "associated", "with", "the", "service", "and", "the", "broker", "if", "provided" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_plan.go#L17-L39
train
cloudfoundry/cli
cf/terminal/table.go
NewTable
func NewTable(headers []string) *Table { pt := &Table{ headers: headers, columnWidth: make([]int, len(headers)), colSpacing: " ", transformer: make([]Transformer, len(headers)), } // Standard colorization, column 0 is auto-highlighted as some // name. Everything else has no transformation (== identity // transform) for i := range pt.transformer { pt.transformer[i] = nop } if 0 < len(headers) { pt.transformer[0] = TableContentHeaderColor } return pt }
go
func NewTable(headers []string) *Table { pt := &Table{ headers: headers, columnWidth: make([]int, len(headers)), colSpacing: " ", transformer: make([]Transformer, len(headers)), } // Standard colorization, column 0 is auto-highlighted as some // name. Everything else has no transformation (== identity // transform) for i := range pt.transformer { pt.transformer[i] = nop } if 0 < len(headers) { pt.transformer[0] = TableContentHeaderColor } return pt }
[ "func", "NewTable", "(", "headers", "[", "]", "string", ")", "*", "Table", "{", "pt", ":=", "&", "Table", "{", "headers", ":", "headers", ",", "columnWidth", ":", "make", "(", "[", "]", "int", ",", "len", "(", "headers", ")", ")", ",", "colSpacing", ":", "\"", "\"", ",", "transformer", ":", "make", "(", "[", "]", "Transformer", ",", "len", "(", "headers", ")", ")", ",", "}", "\n", "// Standard colorization, column 0 is auto-highlighted as some", "// name. Everything else has no transformation (== identity", "// transform)", "for", "i", ":=", "range", "pt", ".", "transformer", "{", "pt", ".", "transformer", "[", "i", "]", "=", "nop", "\n", "}", "\n", "if", "0", "<", "len", "(", "headers", ")", "{", "pt", ".", "transformer", "[", "0", "]", "=", "TableContentHeaderColor", "\n", "}", "\n", "return", "pt", "\n", "}" ]
// NewTable is the constructor function creating a new printable table // from a list of headers. The table is also connected to a UI, which // is where it will print itself to on demand.
[ "NewTable", "is", "the", "constructor", "function", "creating", "a", "new", "printable", "table", "from", "a", "list", "of", "headers", ".", "The", "table", "is", "also", "connected", "to", "a", "UI", "which", "is", "where", "it", "will", "print", "itself", "to", "on", "demand", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L32-L49
train
cloudfoundry/cli
cf/terminal/table.go
SetTransformer
func (t *Table) SetTransformer(columnIndex int, tr Transformer) { t.transformer[columnIndex] = tr }
go
func (t *Table) SetTransformer(columnIndex int, tr Transformer) { t.transformer[columnIndex] = tr }
[ "func", "(", "t", "*", "Table", ")", "SetTransformer", "(", "columnIndex", "int", ",", "tr", "Transformer", ")", "{", "t", ".", "transformer", "[", "columnIndex", "]", "=", "tr", "\n", "}" ]
// SetTransformer specifies a string transformer to apply to the // content of the given column in the specified table.
[ "SetTransformer", "specifies", "a", "string", "transformer", "to", "apply", "to", "the", "content", "of", "the", "given", "column", "in", "the", "specified", "table", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L61-L63
train
cloudfoundry/cli
cf/terminal/table.go
Add
func (t *Table) Add(row ...string) { t.rows = append(t.rows, row) }
go
func (t *Table) Add(row ...string) { t.rows = append(t.rows, row) }
[ "func", "(", "t", "*", "Table", ")", "Add", "(", "row", "...", "string", ")", "{", "t", ".", "rows", "=", "append", "(", "t", ".", "rows", ",", "row", ")", "\n", "}" ]
// Add extends the table by another row.
[ "Add", "extends", "the", "table", "by", "another", "row", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L66-L68
train
cloudfoundry/cli
cf/terminal/table.go
printRow
func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error { height := t.rowHeight[rowIndex] // Compute the index of the last column as the min number of // cells in the header and cells in the current row. // Note: math.Min seems to be for float only :( last := len(t.headers) - 1 lastr := len(row) - 1 if lastr < last { last = lastr } // Note how we always print into a line buffer before placing // the assembled line into the result. This allows us to trim // superfluous trailing whitespace from the line before making // it final. if height <= 1 { // Easy case, all cells in the row are single-line line := &bytes.Buffer{} for columnIndex := range row { // Truncate long row, ignore the additional fields. if columnIndex >= len(t.headers) { break } err := t.printCellValue(line, transformer, columnIndex, last, row[columnIndex]) if err != nil { return err } } fmt.Fprintf(result, "%s\n", trim(string(line.Bytes()))) return nil } // We have at least one multi-line cell in this row. // Treat it a bit like a mini-table. // Step I. Fill the mini-table. Note how it is stored // column-major, not row-major. // [column][row]string sub := make([][]string, len(t.headers)) for columnIndex := range row { // Truncate long row, ignore the additional fields. if columnIndex >= len(t.headers) { break } sub[columnIndex] = strings.Split(row[columnIndex], "\n") // (*) Extend the column to the full height. for len(sub[columnIndex]) < height { sub[columnIndex] = append(sub[columnIndex], "") } } // Step II. Iterate over the rows, then columns to // collect the output. This assumes that all // the rows in sub are the same height. See // (*) above where that is made true. for rowIndex := range sub[0] { line := &bytes.Buffer{} for columnIndex := range sub { err := t.printCellValue(line, transformer, columnIndex, last, sub[columnIndex][rowIndex]) if err != nil { return err } } fmt.Fprintf(result, "%s\n", trim(string(line.Bytes()))) } return nil }
go
func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error { height := t.rowHeight[rowIndex] // Compute the index of the last column as the min number of // cells in the header and cells in the current row. // Note: math.Min seems to be for float only :( last := len(t.headers) - 1 lastr := len(row) - 1 if lastr < last { last = lastr } // Note how we always print into a line buffer before placing // the assembled line into the result. This allows us to trim // superfluous trailing whitespace from the line before making // it final. if height <= 1 { // Easy case, all cells in the row are single-line line := &bytes.Buffer{} for columnIndex := range row { // Truncate long row, ignore the additional fields. if columnIndex >= len(t.headers) { break } err := t.printCellValue(line, transformer, columnIndex, last, row[columnIndex]) if err != nil { return err } } fmt.Fprintf(result, "%s\n", trim(string(line.Bytes()))) return nil } // We have at least one multi-line cell in this row. // Treat it a bit like a mini-table. // Step I. Fill the mini-table. Note how it is stored // column-major, not row-major. // [column][row]string sub := make([][]string, len(t.headers)) for columnIndex := range row { // Truncate long row, ignore the additional fields. if columnIndex >= len(t.headers) { break } sub[columnIndex] = strings.Split(row[columnIndex], "\n") // (*) Extend the column to the full height. for len(sub[columnIndex]) < height { sub[columnIndex] = append(sub[columnIndex], "") } } // Step II. Iterate over the rows, then columns to // collect the output. This assumes that all // the rows in sub are the same height. See // (*) above where that is made true. for rowIndex := range sub[0] { line := &bytes.Buffer{} for columnIndex := range sub { err := t.printCellValue(line, transformer, columnIndex, last, sub[columnIndex][rowIndex]) if err != nil { return err } } fmt.Fprintf(result, "%s\n", trim(string(line.Bytes()))) } return nil }
[ "func", "(", "t", "*", "Table", ")", "printRow", "(", "result", "io", ".", "Writer", ",", "transformer", "rowTransformer", ",", "rowIndex", "int", ",", "row", "[", "]", "string", ")", "error", "{", "height", ":=", "t", ".", "rowHeight", "[", "rowIndex", "]", "\n\n", "// Compute the index of the last column as the min number of", "// cells in the header and cells in the current row.", "// Note: math.Min seems to be for float only :(", "last", ":=", "len", "(", "t", ".", "headers", ")", "-", "1", "\n", "lastr", ":=", "len", "(", "row", ")", "-", "1", "\n", "if", "lastr", "<", "last", "{", "last", "=", "lastr", "\n", "}", "\n\n", "// Note how we always print into a line buffer before placing", "// the assembled line into the result. This allows us to trim", "// superfluous trailing whitespace from the line before making", "// it final.", "if", "height", "<=", "1", "{", "// Easy case, all cells in the row are single-line", "line", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "for", "columnIndex", ":=", "range", "row", "{", "// Truncate long row, ignore the additional fields.", "if", "columnIndex", ">=", "len", "(", "t", ".", "headers", ")", "{", "break", "\n", "}", "\n\n", "err", ":=", "t", ".", "printCellValue", "(", "line", ",", "transformer", ",", "columnIndex", ",", "last", ",", "row", "[", "columnIndex", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "result", ",", "\"", "\\n", "\"", ",", "trim", "(", "string", "(", "line", ".", "Bytes", "(", ")", ")", ")", ")", "\n", "return", "nil", "\n", "}", "\n\n", "// We have at least one multi-line cell in this row.", "// Treat it a bit like a mini-table.", "// Step I. Fill the mini-table. Note how it is stored", "// column-major, not row-major.", "// [column][row]string", "sub", ":=", "make", "(", "[", "]", "[", "]", "string", ",", "len", "(", "t", ".", "headers", ")", ")", "\n", "for", "columnIndex", ":=", "range", "row", "{", "// Truncate long row, ignore the additional fields.", "if", "columnIndex", ">=", "len", "(", "t", ".", "headers", ")", "{", "break", "\n", "}", "\n", "sub", "[", "columnIndex", "]", "=", "strings", ".", "Split", "(", "row", "[", "columnIndex", "]", ",", "\"", "\\n", "\"", ")", "\n", "// (*) Extend the column to the full height.", "for", "len", "(", "sub", "[", "columnIndex", "]", ")", "<", "height", "{", "sub", "[", "columnIndex", "]", "=", "append", "(", "sub", "[", "columnIndex", "]", ",", "\"", "\"", ")", "\n", "}", "\n", "}", "\n\n", "// Step II. Iterate over the rows, then columns to", "// collect the output. This assumes that all", "// the rows in sub are the same height. See", "// (*) above where that is made true.", "for", "rowIndex", ":=", "range", "sub", "[", "0", "]", "{", "line", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n\n", "for", "columnIndex", ":=", "range", "sub", "{", "err", ":=", "t", ".", "printCellValue", "(", "line", ",", "transformer", ",", "columnIndex", ",", "last", ",", "sub", "[", "columnIndex", "]", "[", "rowIndex", "]", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "fmt", ".", "Fprintf", "(", "result", ",", "\"", "\\n", "\"", ",", "trim", "(", "string", "(", "line", ".", "Bytes", "(", ")", ")", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// printRow is responsible for the layouting, transforming and // printing of the string in a single row
[ "printRow", "is", "responsible", "for", "the", "layouting", "transforming", "and", "printing", "of", "the", "string", "in", "a", "single", "row" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L179-L255
train
cloudfoundry/cli
cf/terminal/table.go
printCellValue
func (t *Table) printCellValue(result io.Writer, transformer rowTransformer, col, last int, value string) error { value = trim(transformer.Transform(col, trim(value))) fmt.Fprint(result, value) // Pad all columns, but the last in this row (with the size of // the header row limiting this). This ensures that most of // the irrelevant spacing is not printed. At the moment // irrelevant spacing can only occur when printing a row with // multi-line cells, introducing a physical short line for a // long logical row. Getting rid of that requires fixing in // printRow. // // Note how the inter-column spacing is also irrelevant for // that last column. if col < last { // (**) See also 'calculateMaxSize' (cMS). Here and // there we have to apply identical transformations to // the cell value to get matching cell width // information. If they do not match then we may here // compute a cell width larger than the max width // found by cMS, derive a negative padding length from // that, and subsequently return an error. What was // further missing is trimming before entering the // user-transform. Especially with color transforms // any trailing space going in will not be removable // for print. // // This happened for // https://www.pivotaltracker.com/n/projects/892938/stories/117404629 decolorizedLength, err := visibleSize(trim(Decolorize(value))) if err != nil { return err } padlen := t.columnWidth[col] - decolorizedLength padding := strings.Repeat(" ", padlen) fmt.Fprint(result, padding) fmt.Fprint(result, t.colSpacing) } return nil }
go
func (t *Table) printCellValue(result io.Writer, transformer rowTransformer, col, last int, value string) error { value = trim(transformer.Transform(col, trim(value))) fmt.Fprint(result, value) // Pad all columns, but the last in this row (with the size of // the header row limiting this). This ensures that most of // the irrelevant spacing is not printed. At the moment // irrelevant spacing can only occur when printing a row with // multi-line cells, introducing a physical short line for a // long logical row. Getting rid of that requires fixing in // printRow. // // Note how the inter-column spacing is also irrelevant for // that last column. if col < last { // (**) See also 'calculateMaxSize' (cMS). Here and // there we have to apply identical transformations to // the cell value to get matching cell width // information. If they do not match then we may here // compute a cell width larger than the max width // found by cMS, derive a negative padding length from // that, and subsequently return an error. What was // further missing is trimming before entering the // user-transform. Especially with color transforms // any trailing space going in will not be removable // for print. // // This happened for // https://www.pivotaltracker.com/n/projects/892938/stories/117404629 decolorizedLength, err := visibleSize(trim(Decolorize(value))) if err != nil { return err } padlen := t.columnWidth[col] - decolorizedLength padding := strings.Repeat(" ", padlen) fmt.Fprint(result, padding) fmt.Fprint(result, t.colSpacing) } return nil }
[ "func", "(", "t", "*", "Table", ")", "printCellValue", "(", "result", "io", ".", "Writer", ",", "transformer", "rowTransformer", ",", "col", ",", "last", "int", ",", "value", "string", ")", "error", "{", "value", "=", "trim", "(", "transformer", ".", "Transform", "(", "col", ",", "trim", "(", "value", ")", ")", ")", "\n", "fmt", ".", "Fprint", "(", "result", ",", "value", ")", "\n\n", "// Pad all columns, but the last in this row (with the size of", "// the header row limiting this). This ensures that most of", "// the irrelevant spacing is not printed. At the moment", "// irrelevant spacing can only occur when printing a row with", "// multi-line cells, introducing a physical short line for a", "// long logical row. Getting rid of that requires fixing in", "// printRow.", "//", "// Note how the inter-column spacing is also irrelevant for", "// that last column.", "if", "col", "<", "last", "{", "// (**) See also 'calculateMaxSize' (cMS). Here and", "// there we have to apply identical transformations to", "// the cell value to get matching cell width", "// information. If they do not match then we may here", "// compute a cell width larger than the max width", "// found by cMS, derive a negative padding length from", "// that, and subsequently return an error. What was", "// further missing is trimming before entering the", "// user-transform. Especially with color transforms", "// any trailing space going in will not be removable", "// for print.", "//", "// This happened for", "// https://www.pivotaltracker.com/n/projects/892938/stories/117404629", "decolorizedLength", ",", "err", ":=", "visibleSize", "(", "trim", "(", "Decolorize", "(", "value", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "padlen", ":=", "t", ".", "columnWidth", "[", "col", "]", "-", "decolorizedLength", "\n", "padding", ":=", "strings", ".", "Repeat", "(", "\"", "\"", ",", "padlen", ")", "\n", "fmt", ".", "Fprint", "(", "result", ",", "padding", ")", "\n", "fmt", ".", "Fprint", "(", "result", ",", "t", ".", "colSpacing", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// printCellValue pads the specified string to the width of the given // column, adds the spacing bewtween columns, and returns the result.
[ "printCellValue", "pads", "the", "specified", "string", "to", "the", "width", "of", "the", "given", "column", "adds", "the", "spacing", "bewtween", "columns", "and", "returns", "the", "result", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L259-L300
train
cloudfoundry/cli
cf/terminal/table.go
Transform
func (th *transformHeader) Transform(column int, s string) string { return HeaderColor(s) }
go
func (th *transformHeader) Transform(column int, s string) string { return HeaderColor(s) }
[ "func", "(", "th", "*", "transformHeader", ")", "Transform", "(", "column", "int", ",", "s", "string", ")", "string", "{", "return", "HeaderColor", "(", "s", ")", "\n", "}" ]
// Transform performs the Header highlighting for transformHeader
[ "Transform", "performs", "the", "Header", "highlighting", "for", "transformHeader" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L318-L320
train
cloudfoundry/cli
cf/terminal/table.go
visibleSize
func visibleSize(s string) (int, error) { // This code re-implements the basic functionality of // RuneCountInString to account for special cases. Namely // UTF-8 characters taking up 3 bytes (**) appear as double-width. // // (**) I wonder if that is the set of characters outside of // the BMP <=> the set of characters requiring surrogates (2 // slots) when encoded in UCS-2. r := strings.NewReader(s) var size int for range s { _, runeSize, err := r.ReadRune() if err != nil { return -1, fmt.Errorf("error when calculating visible size of: %s", s) } if runeSize == 3 { size += 2 // Kanji and Katakana characters appear as double-width } else { size++ } } return size, nil }
go
func visibleSize(s string) (int, error) { // This code re-implements the basic functionality of // RuneCountInString to account for special cases. Namely // UTF-8 characters taking up 3 bytes (**) appear as double-width. // // (**) I wonder if that is the set of characters outside of // the BMP <=> the set of characters requiring surrogates (2 // slots) when encoded in UCS-2. r := strings.NewReader(s) var size int for range s { _, runeSize, err := r.ReadRune() if err != nil { return -1, fmt.Errorf("error when calculating visible size of: %s", s) } if runeSize == 3 { size += 2 // Kanji and Katakana characters appear as double-width } else { size++ } } return size, nil }
[ "func", "visibleSize", "(", "s", "string", ")", "(", "int", ",", "error", ")", "{", "// This code re-implements the basic functionality of", "// RuneCountInString to account for special cases. Namely", "// UTF-8 characters taking up 3 bytes (**) appear as double-width.", "//", "// (**) I wonder if that is the set of characters outside of", "// the BMP <=> the set of characters requiring surrogates (2", "// slots) when encoded in UCS-2.", "r", ":=", "strings", ".", "NewReader", "(", "s", ")", "\n\n", "var", "size", "int", "\n", "for", "range", "s", "{", "_", ",", "runeSize", ",", "err", ":=", "r", ".", "ReadRune", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n\n", "if", "runeSize", "==", "3", "{", "size", "+=", "2", "// Kanji and Katakana characters appear as double-width", "\n", "}", "else", "{", "size", "++", "\n", "}", "\n", "}", "\n\n", "return", "size", ",", "nil", "\n", "}" ]
// visibleSize returns the number of columns the string will cover // when displayed in the terminal. This is the number of runes, // i.e. characters, not the number of bytes it consists of.
[ "visibleSize", "returns", "the", "number", "of", "columns", "the", "string", "will", "cover", "when", "displayed", "in", "the", "terminal", ".", "This", "is", "the", "number", "of", "runes", "i", ".", "e", ".", "characters", "not", "the", "number", "of", "bytes", "it", "consists", "of", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L344-L370
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
DeleteIsolationSegmentOrganization
func (client *Client) DeleteIsolationSegmentOrganization(isolationSegmentGUID string, orgGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteIsolationSegmentRelationshipOrganizationRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID, "organization_guid": orgGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteIsolationSegmentOrganization(isolationSegmentGUID string, orgGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteIsolationSegmentRelationshipOrganizationRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID, "organization_guid": orgGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteIsolationSegmentOrganization", "(", "isolationSegmentGUID", "string", ",", "orgGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteIsolationSegmentRelationshipOrganizationRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "isolationSegmentGUID", ",", "\"", "\"", ":", "orgGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteIsolationSegmentOrganization will delete the relationship between // the isolation segment and the organization provided.
[ "DeleteIsolationSegmentOrganization", "will", "delete", "the", "relationship", "between", "the", "isolation", "segment", "and", "the", "organization", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L53-L66
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
DeleteServiceInstanceRelationshipsSharedSpace
func (client *Client) DeleteServiceInstanceRelationshipsSharedSpace(serviceInstanceGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceInstanceRelationshipsSharedSpaceRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID, "space_guid": spaceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteServiceInstanceRelationshipsSharedSpace(serviceInstanceGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceInstanceRelationshipsSharedSpaceRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID, "space_guid": spaceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteServiceInstanceRelationshipsSharedSpace", "(", "serviceInstanceGUID", "string", ",", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteServiceInstanceRelationshipsSharedSpaceRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "serviceInstanceGUID", ",", "\"", "\"", ":", "spaceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteServiceInstanceRelationshipsSharedSpace will delete the sharing relationship // between the service instance and the shared-to space provided.
[ "DeleteServiceInstanceRelationshipsSharedSpace", "will", "delete", "the", "sharing", "relationship", "between", "the", "service", "instance", "and", "the", "shared", "-", "to", "space", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L70-L82
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
GetOrganizationDefaultIsolationSegment
func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (Relationship, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationRelationshipDefaultIsolationSegmentRequest, URIParams: internal.Params{"organization_guid": orgGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
go
func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (Relationship, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationRelationshipDefaultIsolationSegmentRequest, URIParams: internal.Params{"organization_guid": orgGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizationDefaultIsolationSegment", "(", "orgGUID", "string", ")", "(", "Relationship", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationRelationshipDefaultIsolationSegmentRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "orgGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationship", "Relationship", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationship", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationship", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetOrganizationDefaultIsolationSegment returns the relationship between an // organization and it's default isolation segment.
[ "GetOrganizationDefaultIsolationSegment", "returns", "the", "relationship", "between", "an", "organization", "and", "it", "s", "default", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L86-L102
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
GetSpaceIsolationSegment
func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (Relationship, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRelationshipIsolationSegmentRequest, URIParams: internal.Params{"space_guid": spaceGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
go
func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (Relationship, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRelationshipIsolationSegmentRequest, URIParams: internal.Params{"space_guid": spaceGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceIsolationSegment", "(", "spaceGUID", "string", ")", "(", "Relationship", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpaceRelationshipIsolationSegmentRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationship", "Relationship", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationship", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationship", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetSpaceIsolationSegment returns the relationship between a space and it's // isolation segment.
[ "GetSpaceIsolationSegment", "returns", "the", "relationship", "between", "a", "space", "and", "it", "s", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L106-L122
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
SetApplicationDroplet
func (client *Client) SetApplicationDroplet(appGUID string, dropletGUID string) (Relationship, Warnings, error) { relationship := Relationship{GUID: dropletGUID} bodyBytes, err := json.Marshal(relationship) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationCurrentDropletRequest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Relationship{}, nil, err } var responseRelationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseRelationship, } err = client.connection.Make(request, &response) return responseRelationship, response.Warnings, err }
go
func (client *Client) SetApplicationDroplet(appGUID string, dropletGUID string) (Relationship, Warnings, error) { relationship := Relationship{GUID: dropletGUID} bodyBytes, err := json.Marshal(relationship) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationCurrentDropletRequest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Relationship{}, nil, err } var responseRelationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseRelationship, } err = client.connection.Make(request, &response) return responseRelationship, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "SetApplicationDroplet", "(", "appGUID", "string", ",", "dropletGUID", "string", ")", "(", "Relationship", ",", "Warnings", ",", "error", ")", "{", "relationship", ":=", "Relationship", "{", "GUID", ":", "dropletGUID", "}", "\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "relationship", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchApplicationCurrentDropletRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseRelationship", "Relationship", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseRelationship", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responseRelationship", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// SetApplicationDroplet sets the specified droplet on the given application.
[ "SetApplicationDroplet", "sets", "the", "specified", "droplet", "on", "the", "given", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L125-L148
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
UpdateOrganizationDefaultIsolationSegmentRelationship
func (client *Client) UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID string, isoSegGUID string) (Relationship, Warnings, error) { body, err := json.Marshal(Relationship{GUID: isoSegGUID}) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchOrganizationRelationshipDefaultIsolationSegmentRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"organization_guid": orgGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
go
func (client *Client) UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID string, isoSegGUID string) (Relationship, Warnings, error) { body, err := json.Marshal(Relationship{GUID: isoSegGUID}) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchOrganizationRelationshipDefaultIsolationSegmentRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"organization_guid": orgGUID}, }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateOrganizationDefaultIsolationSegmentRelationship", "(", "orgGUID", "string", ",", "isoSegGUID", "string", ")", "(", "Relationship", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "Relationship", "{", "GUID", ":", "isoSegGUID", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchOrganizationRelationshipDefaultIsolationSegmentRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "orgGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationship", "Relationship", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationship", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationship", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateOrganizationDefaultIsolationSegmentRelationship sets the default isolation segment // for an organization on the controller. // If isoSegGuid is empty it will reset the default isolation segment.
[ "UpdateOrganizationDefaultIsolationSegmentRelationship", "sets", "the", "default", "isolation", "segment", "for", "an", "organization", "on", "the", "controller", ".", "If", "isoSegGuid", "is", "empty", "it", "will", "reset", "the", "default", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L153-L174
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship.go
UpdateSpaceIsolationSegmentRelationship
func (client *Client) UpdateSpaceIsolationSegmentRelationship(spaceGUID string, isolationSegmentGUID string) (Relationship, Warnings, error) { body, err := json.Marshal(Relationship{GUID: isolationSegmentGUID}) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchSpaceRelationshipIsolationSegmentRequest, URIParams: internal.Params{"space_guid": spaceGUID}, Body: bytes.NewReader(body), }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
go
func (client *Client) UpdateSpaceIsolationSegmentRelationship(spaceGUID string, isolationSegmentGUID string) (Relationship, Warnings, error) { body, err := json.Marshal(Relationship{GUID: isolationSegmentGUID}) if err != nil { return Relationship{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchSpaceRelationshipIsolationSegmentRequest, URIParams: internal.Params{"space_guid": spaceGUID}, Body: bytes.NewReader(body), }) if err != nil { return Relationship{}, nil, err } var relationship Relationship response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationship, } err = client.connection.Make(request, &response) return relationship, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateSpaceIsolationSegmentRelationship", "(", "spaceGUID", "string", ",", "isolationSegmentGUID", "string", ")", "(", "Relationship", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "Relationship", "{", "GUID", ":", "isolationSegmentGUID", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchSpaceRelationshipIsolationSegmentRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Relationship", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationship", "Relationship", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationship", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationship", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateSpaceIsolationSegmentRelationship assigns an isolation segment to a space and // returns the relationship.
[ "UpdateSpaceIsolationSegmentRelationship", "assigns", "an", "isolation", "segment", "to", "a", "space", "and", "returns", "the", "relationship", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L178-L200
train
cloudfoundry/cli
cf/terminal/ui_unix.go
echoOn
func echoOn(fd []uintptr) { // Turn on the terminal echo. pid, e := syscall.ForkExec(sttyArg0, sttyArgvEOn, &syscall.ProcAttr{Dir: execCWDir, Files: fd}) if e == nil { _, _ = syscall.Wait4(pid, &ws, 0, nil) } }
go
func echoOn(fd []uintptr) { // Turn on the terminal echo. pid, e := syscall.ForkExec(sttyArg0, sttyArgvEOn, &syscall.ProcAttr{Dir: execCWDir, Files: fd}) if e == nil { _, _ = syscall.Wait4(pid, &ws, 0, nil) } }
[ "func", "echoOn", "(", "fd", "[", "]", "uintptr", ")", "{", "// Turn on the terminal echo.", "pid", ",", "e", ":=", "syscall", ".", "ForkExec", "(", "sttyArg0", ",", "sttyArgvEOn", ",", "&", "syscall", ".", "ProcAttr", "{", "Dir", ":", "execCWDir", ",", "Files", ":", "fd", "}", ")", "\n\n", "if", "e", "==", "nil", "{", "_", ",", "_", "=", "syscall", ".", "Wait4", "(", "pid", ",", "&", "ws", ",", "0", ",", "nil", ")", "\n", "}", "\n", "}" ]
// echoOn turns back on the terminal echo.
[ "echoOn", "turns", "back", "on", "the", "terminal", "echo", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui_unix.go#L84-L91
train
cloudfoundry/cli
cf/terminal/ui_unix.go
catchSignal
func catchSignal(fd []uintptr, sig chan os.Signal) { select { case <-sig: echoOn(fd) os.Exit(2) } }
go
func catchSignal(fd []uintptr, sig chan os.Signal) { select { case <-sig: echoOn(fd) os.Exit(2) } }
[ "func", "catchSignal", "(", "fd", "[", "]", "uintptr", ",", "sig", "chan", "os", ".", "Signal", ")", "{", "select", "{", "case", "<-", "sig", ":", "echoOn", "(", "fd", ")", "\n", "os", ".", "Exit", "(", "2", ")", "\n", "}", "\n", "}" ]
// catchSignal tries to catch SIGKILL, SIGQUIT and SIGINT so that we can turn terminal // echo back on before the program ends. Otherwise the user is left with echo off on // their terminal.
[ "catchSignal", "tries", "to", "catch", "SIGKILL", "SIGQUIT", "and", "SIGINT", "so", "that", "we", "can", "turn", "terminal", "echo", "back", "on", "before", "the", "program", "ends", ".", "Otherwise", "the", "user", "is", "left", "with", "echo", "off", "on", "their", "terminal", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui_unix.go#L96-L102
train
cloudfoundry/cli
actor/v3action/task.go
RunTask
func (actor Actor) RunTask(appGUID string, task Task) (Task, Warnings, error) { createdTask, warnings, err := actor.CloudControllerClient.CreateApplicationTask(appGUID, ccv3.Task(task)) if err != nil { if e, ok := err.(ccerror.TaskWorkersUnavailableError); ok { return Task{}, Warnings(warnings), actionerror.TaskWorkersUnavailableError{Message: e.Error()} } } return Task(createdTask), Warnings(warnings), err }
go
func (actor Actor) RunTask(appGUID string, task Task) (Task, Warnings, error) { createdTask, warnings, err := actor.CloudControllerClient.CreateApplicationTask(appGUID, ccv3.Task(task)) if err != nil { if e, ok := err.(ccerror.TaskWorkersUnavailableError); ok { return Task{}, Warnings(warnings), actionerror.TaskWorkersUnavailableError{Message: e.Error()} } } return Task(createdTask), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "RunTask", "(", "appGUID", "string", ",", "task", "Task", ")", "(", "Task", ",", "Warnings", ",", "error", ")", "{", "createdTask", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateApplicationTask", "(", "appGUID", ",", "ccv3", ".", "Task", "(", "task", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "e", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "TaskWorkersUnavailableError", ")", ";", "ok", "{", "return", "Task", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "TaskWorkersUnavailableError", "{", "Message", ":", "e", ".", "Error", "(", ")", "}", "\n", "}", "\n", "}", "\n\n", "return", "Task", "(", "createdTask", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// RunTask runs the provided command in the application environment associated // with the provided application GUID.
[ "RunTask", "runs", "the", "provided", "command", "in", "the", "application", "environment", "associated", "with", "the", "provided", "application", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/task.go#L18-L27
train
cloudfoundry/cli
actor/v3action/task.go
GetApplicationTasks
func (actor Actor) GetApplicationTasks(appGUID string, sortOrder SortOrder) ([]Task, Warnings, error) { tasks, warnings, err := actor.CloudControllerClient.GetApplicationTasks(appGUID) actorWarnings := Warnings(warnings) if err != nil { return nil, actorWarnings, err } allTasks := []Task{} for _, task := range tasks { allTasks = append(allTasks, Task(task)) } if sortOrder == Descending { sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID > allTasks[j].SequenceID }) } else { sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID < allTasks[j].SequenceID }) } return allTasks, actorWarnings, nil }
go
func (actor Actor) GetApplicationTasks(appGUID string, sortOrder SortOrder) ([]Task, Warnings, error) { tasks, warnings, err := actor.CloudControllerClient.GetApplicationTasks(appGUID) actorWarnings := Warnings(warnings) if err != nil { return nil, actorWarnings, err } allTasks := []Task{} for _, task := range tasks { allTasks = append(allTasks, Task(task)) } if sortOrder == Descending { sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID > allTasks[j].SequenceID }) } else { sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID < allTasks[j].SequenceID }) } return allTasks, actorWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetApplicationTasks", "(", "appGUID", "string", ",", "sortOrder", "SortOrder", ")", "(", "[", "]", "Task", ",", "Warnings", ",", "error", ")", "{", "tasks", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationTasks", "(", "appGUID", ")", "\n", "actorWarnings", ":=", "Warnings", "(", "warnings", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "actorWarnings", ",", "err", "\n", "}", "\n\n", "allTasks", ":=", "[", "]", "Task", "{", "}", "\n", "for", "_", ",", "task", ":=", "range", "tasks", "{", "allTasks", "=", "append", "(", "allTasks", ",", "Task", "(", "task", ")", ")", "\n", "}", "\n\n", "if", "sortOrder", "==", "Descending", "{", "sort", ".", "Slice", "(", "allTasks", ",", "func", "(", "i", "int", ",", "j", "int", ")", "bool", "{", "return", "allTasks", "[", "i", "]", ".", "SequenceID", ">", "allTasks", "[", "j", "]", ".", "SequenceID", "}", ")", "\n", "}", "else", "{", "sort", ".", "Slice", "(", "allTasks", ",", "func", "(", "i", "int", ",", "j", "int", ")", "bool", "{", "return", "allTasks", "[", "i", "]", ".", "SequenceID", "<", "allTasks", "[", "j", "]", ".", "SequenceID", "}", ")", "\n", "}", "\n\n", "return", "allTasks", ",", "actorWarnings", ",", "nil", "\n", "}" ]
// GetApplicationTasks returns a list of tasks associated with the provided // appplication GUID.
[ "GetApplicationTasks", "returns", "a", "list", "of", "tasks", "associated", "with", "the", "provided", "appplication", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/task.go#L31-L50
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
UnmarshalJSON
func (org *Organization) UnmarshalJSON(data []byte) error { var ccOrg struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` QuotaDefinitionGUID string `json:"quota_definition_guid"` DefaultIsolationSegmentGUID string `json:"default_isolation_segment_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrg) if err != nil { return err } org.GUID = ccOrg.Metadata.GUID org.Name = ccOrg.Entity.Name org.QuotaDefinitionGUID = ccOrg.Entity.QuotaDefinitionGUID org.DefaultIsolationSegmentGUID = ccOrg.Entity.DefaultIsolationSegmentGUID return nil }
go
func (org *Organization) UnmarshalJSON(data []byte) error { var ccOrg struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` QuotaDefinitionGUID string `json:"quota_definition_guid"` DefaultIsolationSegmentGUID string `json:"default_isolation_segment_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrg) if err != nil { return err } org.GUID = ccOrg.Metadata.GUID org.Name = ccOrg.Entity.Name org.QuotaDefinitionGUID = ccOrg.Entity.QuotaDefinitionGUID org.DefaultIsolationSegmentGUID = ccOrg.Entity.DefaultIsolationSegmentGUID return nil }
[ "func", "(", "org", "*", "Organization", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccOrg", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "QuotaDefinitionGUID", "string", "`json:\"quota_definition_guid\"`", "\n", "DefaultIsolationSegmentGUID", "string", "`json:\"default_isolation_segment_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccOrg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "org", ".", "GUID", "=", "ccOrg", ".", "Metadata", ".", "GUID", "\n", "org", ".", "Name", "=", "ccOrg", ".", "Entity", ".", "Name", "\n", "org", ".", "QuotaDefinitionGUID", "=", "ccOrg", ".", "Entity", ".", "QuotaDefinitionGUID", "\n", "org", ".", "DefaultIsolationSegmentGUID", "=", "ccOrg", ".", "Entity", ".", "DefaultIsolationSegmentGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Organization response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Organization", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L32-L51
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
GetOrganization
func (client *Client) GetOrganization(guid string) (Organization, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationRequest, URIParams: Params{"organization_guid": guid}, }) if err != nil { return Organization{}, nil, err } var org Organization response := cloudcontroller.Response{ DecodeJSONResponseInto: &org, } err = client.connection.Make(request, &response) return org, response.Warnings, err }
go
func (client *Client) GetOrganization(guid string) (Organization, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationRequest, URIParams: Params{"organization_guid": guid}, }) if err != nil { return Organization{}, nil, err } var org Organization response := cloudcontroller.Response{ DecodeJSONResponseInto: &org, } err = client.connection.Make(request, &response) return org, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganization", "(", "guid", "string", ")", "(", "Organization", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Organization", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "org", "Organization", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "org", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "org", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetOrganization returns an Organization associated with the provided GUID.
[ "GetOrganization", "returns", "an", "Organization", "associated", "with", "the", "provided", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L113-L129
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
GetOrganizations
func (client *Client) GetOrganizations(filters ...Filter) ([]Organization, Warnings, error) { allQueries := ConvertFilterParameters(filters) allQueries.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationsRequest, Query: allQueries, }) if err != nil { return nil, nil, err } var fullOrgsList []Organization warnings, err := client.paginate(request, Organization{}, func(item interface{}) error { if org, ok := item.(Organization); ok { fullOrgsList = append(fullOrgsList, org) } else { return ccerror.UnknownObjectInListError{ Expected: Organization{}, Unexpected: item, } } return nil }) return fullOrgsList, warnings, err }
go
func (client *Client) GetOrganizations(filters ...Filter) ([]Organization, Warnings, error) { allQueries := ConvertFilterParameters(filters) allQueries.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationsRequest, Query: allQueries, }) if err != nil { return nil, nil, err } var fullOrgsList []Organization warnings, err := client.paginate(request, Organization{}, func(item interface{}) error { if org, ok := item.(Organization); ok { fullOrgsList = append(fullOrgsList, org) } else { return ccerror.UnknownObjectInListError{ Expected: Organization{}, Unexpected: item, } } return nil }) return fullOrgsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizations", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Organization", ",", "Warnings", ",", "error", ")", "{", "allQueries", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n", "allQueries", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationsRequest", ",", "Query", ":", "allQueries", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullOrgsList", "[", "]", "Organization", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Organization", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "org", ",", "ok", ":=", "item", ".", "(", "Organization", ")", ";", "ok", "{", "fullOrgsList", "=", "append", "(", "fullOrgsList", ",", "org", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Organization", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullOrgsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetOrganizations returns back a list of Organizations based off of the // provided filters.
[ "GetOrganizations", "returns", "back", "a", "list", "of", "Organizations", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L133-L159
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
UpdateOrganizationManager
func (client *Client) UpdateOrganizationManager(guid string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationManagerRequest, URIParams: Params{"organization_guid": guid, "manager_guid": uaaID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateOrganizationManager(guid string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationManagerRequest, URIParams: Params{"organization_guid": guid, "manager_guid": uaaID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateOrganizationManager", "(", "guid", "string", ",", "uaaID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutOrganizationManagerRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", ",", "\"", "\"", ":", "uaaID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateOrganizationManager assigns the org manager role to the UAA user or client with the provided ID.
[ "UpdateOrganizationManager", "assigns", "the", "org", "manager", "role", "to", "the", "UAA", "user", "or", "client", "with", "the", "provided", "ID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L166-L179
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
UpdateOrganizationManagerByUsername
func (client *Client) UpdateOrganizationManagerByUsername(guid string, username string) (Warnings, error) { requestBody := updateOrgManagerByUsernameRequestBody{ Username: username, } body, err := json.Marshal(requestBody) if err != nil { return nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationManagerByUsernameRequest, Body: bytes.NewReader(body), URIParams: Params{"organization_guid": guid}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateOrganizationManagerByUsername(guid string, username string) (Warnings, error) { requestBody := updateOrgManagerByUsernameRequestBody{ Username: username, } body, err := json.Marshal(requestBody) if err != nil { return nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationManagerByUsernameRequest, Body: bytes.NewReader(body), URIParams: Params{"organization_guid": guid}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateOrganizationManagerByUsername", "(", "guid", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "updateOrgManagerByUsernameRequestBody", "{", "Username", ":", "username", ",", "}", "\n\n", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutOrganizationManagerByUsernameRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateOrganizationManagerByUsername assigns the org manager role to the user with the provided name.
[ "UpdateOrganizationManagerByUsername", "assigns", "the", "org", "manager", "role", "to", "the", "user", "with", "the", "provided", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L182-L205
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization.go
UpdateOrganizationUserByUsername
func (client Client) UpdateOrganizationUserByUsername(orgGUID string, username string) (Warnings, error) { requestBody := updateOrgUserByUsernameRequestBody{ Username: username, } body, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationUserByUsernameRequest, Body: bytes.NewReader(body), URIParams: Params{"organization_guid": orgGUID}, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client Client) UpdateOrganizationUserByUsername(orgGUID string, username string) (Warnings, error) { requestBody := updateOrgUserByUsernameRequestBody{ Username: username, } body, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutOrganizationUserByUsernameRequest, Body: bytes.NewReader(body), URIParams: Params{"organization_guid": orgGUID}, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "Client", ")", "UpdateOrganizationUserByUsername", "(", "orgGUID", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "updateOrgUserByUsernameRequestBody", "{", "Username", ":", "username", ",", "}", "\n\n", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutOrganizationUserByUsernameRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "orgGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateOrganizationUserByUsername makes the user with the given username a member of // the org.
[ "UpdateOrganizationUserByUsername", "makes", "the", "user", "with", "the", "given", "username", "a", "member", "of", "the", "org", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L230-L253
train
cloudfoundry/cli
api/cloudcontroller/ccv3/query.go
FormatQueryParameters
func FormatQueryParameters(queries []Query) url.Values { params := url.Values{} for _, query := range queries { params.Add(string(query.Key), strings.Join(query.Values, ",")) } return params }
go
func FormatQueryParameters(queries []Query) url.Values { params := url.Values{} for _, query := range queries { params.Add(string(query.Key), strings.Join(query.Values, ",")) } return params }
[ "func", "FormatQueryParameters", "(", "queries", "[", "]", "Query", ")", "url", ".", "Values", "{", "params", ":=", "url", ".", "Values", "{", "}", "\n", "for", "_", ",", "query", ":=", "range", "queries", "{", "params", ".", "Add", "(", "string", "(", "query", ".", "Key", ")", ",", "strings", ".", "Join", "(", "query", ".", "Values", ",", "\"", "\"", ")", ")", "\n", "}", "\n\n", "return", "params", "\n", "}" ]
// FormatQueryParameters converts a Query object into a collection that // cloudcontroller.Request can accept.
[ "FormatQueryParameters", "converts", "a", "Query", "object", "into", "a", "collection", "that", "cloudcontroller", ".", "Request", "can", "accept", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/query.go#L52-L59
train
cloudfoundry/cli
api/uaa/noaabridge/token_refresher.go
NewTokenRefresher
func NewTokenRefresher(uaaClient UAAClient, cache TokenCache) *TokenRefresher { return &TokenRefresher{ uaaClient: uaaClient, cache: cache, } }
go
func NewTokenRefresher(uaaClient UAAClient, cache TokenCache) *TokenRefresher { return &TokenRefresher{ uaaClient: uaaClient, cache: cache, } }
[ "func", "NewTokenRefresher", "(", "uaaClient", "UAAClient", ",", "cache", "TokenCache", ")", "*", "TokenRefresher", "{", "return", "&", "TokenRefresher", "{", "uaaClient", ":", "uaaClient", ",", "cache", ":", "cache", ",", "}", "\n", "}" ]
// NewTokenRefresher returns back a pointer to a TokenRefresher.
[ "NewTokenRefresher", "returns", "back", "a", "pointer", "to", "a", "TokenRefresher", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/noaabridge/token_refresher.go#L31-L36
train
cloudfoundry/cli
api/uaa/noaabridge/token_refresher.go
RefreshAuthToken
func (t *TokenRefresher) RefreshAuthToken() (string, error) { tokens, err := t.uaaClient.RefreshAccessToken(t.cache.RefreshToken()) if err != nil { return "", err } t.cache.SetAccessToken(tokens.AuthorizationToken()) t.cache.SetRefreshToken(tokens.RefreshToken) return tokens.AuthorizationToken(), nil }
go
func (t *TokenRefresher) RefreshAuthToken() (string, error) { tokens, err := t.uaaClient.RefreshAccessToken(t.cache.RefreshToken()) if err != nil { return "", err } t.cache.SetAccessToken(tokens.AuthorizationToken()) t.cache.SetRefreshToken(tokens.RefreshToken) return tokens.AuthorizationToken(), nil }
[ "func", "(", "t", "*", "TokenRefresher", ")", "RefreshAuthToken", "(", ")", "(", "string", ",", "error", ")", "{", "tokens", ",", "err", ":=", "t", ".", "uaaClient", ".", "RefreshAccessToken", "(", "t", ".", "cache", ".", "RefreshToken", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "t", ".", "cache", ".", "SetAccessToken", "(", "tokens", ".", "AuthorizationToken", "(", ")", ")", "\n", "t", ".", "cache", ".", "SetRefreshToken", "(", "tokens", ".", "RefreshToken", ")", "\n", "return", "tokens", ".", "AuthorizationToken", "(", ")", ",", "nil", "\n", "}" ]
// RefreshAuthToken refreshes the current Authorization Token and stores the // Access and Refresh token in it's cache. The returned Authorization Token // includes the type prefixed by a space.
[ "RefreshAuthToken", "refreshes", "the", "current", "Authorization", "Token", "and", "stores", "the", "Access", "and", "Refresh", "token", "in", "it", "s", "cache", ".", "The", "returned", "Authorization", "Token", "includes", "the", "type", "prefixed", "by", "a", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/noaabridge/token_refresher.go#L41-L50
train
cloudfoundry/cli
api/cloudcontroller/pipebomb.go
Seek
func (*Pipebomb) Seek(offset int64, whence int) (int64, error) { return 0, ccerror.PipeSeekError{} }
go
func (*Pipebomb) Seek(offset int64, whence int) (int64, error) { return 0, ccerror.PipeSeekError{} }
[ "func", "(", "*", "Pipebomb", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "int64", ",", "error", ")", "{", "return", "0", ",", "ccerror", ".", "PipeSeekError", "{", "}", "\n", "}" ]
// Seek returns a PipeSeekError; allowing the top level calling function to // handle the retry instead of seeking back to the beginning of the Reader.
[ "Seek", "returns", "a", "PipeSeekError", ";", "allowing", "the", "top", "level", "calling", "function", "to", "handle", "the", "retry", "instead", "of", "seeking", "back", "to", "the", "beginning", "of", "the", "Reader", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/pipebomb.go#L18-L20
train
cloudfoundry/cli
api/cloudcontroller/pipebomb.go
NewPipeBomb
func NewPipeBomb() (*Pipebomb, io.WriteCloser) { writerOutput, writerInput := io.Pipe() return &Pipebomb{ReadCloser: writerOutput}, writerInput }
go
func NewPipeBomb() (*Pipebomb, io.WriteCloser) { writerOutput, writerInput := io.Pipe() return &Pipebomb{ReadCloser: writerOutput}, writerInput }
[ "func", "NewPipeBomb", "(", ")", "(", "*", "Pipebomb", ",", "io", ".", "WriteCloser", ")", "{", "writerOutput", ",", "writerInput", ":=", "io", ".", "Pipe", "(", ")", "\n", "return", "&", "Pipebomb", "{", "ReadCloser", ":", "writerOutput", "}", ",", "writerInput", "\n", "}" ]
// NewPipeBomb returns an io.WriteCloser that can be used to stream data to a // the Pipebomb.
[ "NewPipeBomb", "returns", "an", "io", ".", "WriteCloser", "that", "can", "be", "used", "to", "stream", "data", "to", "a", "the", "Pipebomb", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/pipebomb.go#L24-L27
train
cloudfoundry/cli
actor/v2action/service_binding.go
BindServiceByApplicationAndServiceInstance
func (actor Actor) BindServiceByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.CreateServiceBinding(appGUID, serviceInstanceGUID, "", false, nil) return Warnings(warnings), err }
go
func (actor Actor) BindServiceByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.CreateServiceBinding(appGUID, serviceInstanceGUID, "", false, nil) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "BindServiceByApplicationAndServiceInstance", "(", "appGUID", "string", ",", "serviceInstanceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateServiceBinding", "(", "appGUID", ",", "serviceInstanceGUID", ",", "\"", "\"", ",", "false", ",", "nil", ")", "\n\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// BindServiceByApplicationAndServiceInstance binds the service instance to an application.
[ "BindServiceByApplicationAndServiceInstance", "binds", "the", "service", "instance", "to", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L18-L22
train
cloudfoundry/cli
actor/v2action/service_binding.go
BindServiceBySpace
func (actor Actor) BindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string, bindingName string, parameters map[string]interface{}) (ServiceBinding, Warnings, error) { var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceBinding, ccv2Warnings, err := actor.CloudControllerClient.CreateServiceBinding(app.GUID, serviceInstance.GUID, bindingName, true, parameters) allWarnings = append(allWarnings, ccv2Warnings...) return ServiceBinding(serviceBinding), allWarnings, err }
go
func (actor Actor) BindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string, bindingName string, parameters map[string]interface{}) (ServiceBinding, Warnings, error) { var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceBinding, ccv2Warnings, err := actor.CloudControllerClient.CreateServiceBinding(app.GUID, serviceInstance.GUID, bindingName, true, parameters) allWarnings = append(allWarnings, ccv2Warnings...) return ServiceBinding(serviceBinding), allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "BindServiceBySpace", "(", "appName", "string", ",", "serviceInstanceName", "string", ",", "spaceGUID", "string", ",", "bindingName", "string", ",", "parameters", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "serviceInstance", ",", "warnings", ",", "err", ":=", "actor", ".", "GetServiceInstanceByNameAndSpace", "(", "serviceInstanceName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "serviceBinding", ",", "ccv2Warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateServiceBinding", "(", "app", ".", "GUID", ",", "serviceInstance", ".", "GUID", ",", "bindingName", ",", "true", ",", "parameters", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "ccv2Warnings", "...", ")", "\n\n", "return", "ServiceBinding", "(", "serviceBinding", ")", ",", "allWarnings", ",", "err", "\n", "}" ]
// BindServiceBySpace binds the service instance to an application for a given space.
[ "BindServiceBySpace", "binds", "the", "service", "instance", "to", "an", "application", "for", "a", "given", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L25-L43
train
cloudfoundry/cli
actor/v2action/service_binding.go
GetServiceBindingByApplicationAndServiceInstance
func (actor Actor) GetServiceBindingByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (ServiceBinding, Warnings, error) { serviceBindings, warnings, err := actor.CloudControllerClient.GetServiceBindings( ccv2.Filter{ Type: constant.AppGUIDFilter, Operator: constant.EqualOperator, Values: []string{appGUID}, }, ccv2.Filter{ Type: constant.ServiceInstanceGUIDFilter, Operator: constant.EqualOperator, Values: []string{serviceInstanceGUID}, }, ) if err != nil { return ServiceBinding{}, Warnings(warnings), err } if len(serviceBindings) == 0 { return ServiceBinding{}, Warnings(warnings), actionerror.ServiceBindingNotFoundError{ AppGUID: appGUID, ServiceInstanceGUID: serviceInstanceGUID, } } return ServiceBinding(serviceBindings[0]), Warnings(warnings), err }
go
func (actor Actor) GetServiceBindingByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (ServiceBinding, Warnings, error) { serviceBindings, warnings, err := actor.CloudControllerClient.GetServiceBindings( ccv2.Filter{ Type: constant.AppGUIDFilter, Operator: constant.EqualOperator, Values: []string{appGUID}, }, ccv2.Filter{ Type: constant.ServiceInstanceGUIDFilter, Operator: constant.EqualOperator, Values: []string{serviceInstanceGUID}, }, ) if err != nil { return ServiceBinding{}, Warnings(warnings), err } if len(serviceBindings) == 0 { return ServiceBinding{}, Warnings(warnings), actionerror.ServiceBindingNotFoundError{ AppGUID: appGUID, ServiceInstanceGUID: serviceInstanceGUID, } } return ServiceBinding(serviceBindings[0]), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetServiceBindingByApplicationAndServiceInstance", "(", "appGUID", "string", ",", "serviceInstanceGUID", "string", ")", "(", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "serviceBindings", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServiceBindings", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "AppGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "appGUID", "}", ",", "}", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "ServiceInstanceGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "serviceInstanceGUID", "}", ",", "}", ",", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "serviceBindings", ")", "==", "0", "{", "return", "ServiceBinding", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ServiceBindingNotFoundError", "{", "AppGUID", ":", "appGUID", ",", "ServiceInstanceGUID", ":", "serviceInstanceGUID", ",", "}", "\n", "}", "\n\n", "return", "ServiceBinding", "(", "serviceBindings", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetServiceBindingByApplicationAndServiceInstance returns a service binding // given an application GUID and and service instance GUID.
[ "GetServiceBindingByApplicationAndServiceInstance", "returns", "a", "service", "binding", "given", "an", "application", "GUID", "and", "and", "service", "instance", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L47-L73
train
cloudfoundry/cli
actor/v2action/service_binding.go
UnbindServiceBySpace
func (actor Actor) UnbindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string) (ServiceBinding, Warnings, error) { var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceBinding, warnings, err := actor.GetServiceBindingByApplicationAndServiceInstance(app.GUID, serviceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } deletedBinding, ccWarnings, err := actor.CloudControllerClient.DeleteServiceBinding(serviceBinding.GUID, true) allWarnings = append(allWarnings, ccWarnings...) return ServiceBinding(deletedBinding), allWarnings, err }
go
func (actor Actor) UnbindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string) (ServiceBinding, Warnings, error) { var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } serviceBinding, warnings, err := actor.GetServiceBindingByApplicationAndServiceInstance(app.GUID, serviceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceBinding{}, allWarnings, err } deletedBinding, ccWarnings, err := actor.CloudControllerClient.DeleteServiceBinding(serviceBinding.GUID, true) allWarnings = append(allWarnings, ccWarnings...) return ServiceBinding(deletedBinding), allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "UnbindServiceBySpace", "(", "appName", "string", ",", "serviceInstanceName", "string", ",", "spaceGUID", "string", ")", "(", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n\n", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "serviceInstance", ",", "warnings", ",", "err", ":=", "actor", ".", "GetServiceInstanceByNameAndSpace", "(", "serviceInstanceName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "serviceBinding", ",", "warnings", ",", "err", ":=", "actor", ".", "GetServiceBindingByApplicationAndServiceInstance", "(", "app", ".", "GUID", ",", "serviceInstance", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "deletedBinding", ",", "ccWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "DeleteServiceBinding", "(", "serviceBinding", ".", "GUID", ",", "true", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "ccWarnings", "...", ")", "\n\n", "return", "ServiceBinding", "(", "deletedBinding", ")", ",", "allWarnings", ",", "err", "\n", "}" ]
// UnbindServiceBySpace deletes the service binding between an application and // service instance for a given space.
[ "UnbindServiceBySpace", "deletes", "the", "service", "binding", "between", "an", "application", "and", "service", "instance", "for", "a", "given", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L77-L102
train
cloudfoundry/cli
integration/helpers/sha.go
Sha1Sum
func Sha1Sum(path string) string { f, err := os.Open(path) Expect(err).ToNot(HaveOccurred()) defer f.Close() hash := sha1.New() _, err = io.Copy(hash, f) Expect(err).ToNot(HaveOccurred()) return fmt.Sprintf("%x", hash.Sum(nil)) }
go
func Sha1Sum(path string) string { f, err := os.Open(path) Expect(err).ToNot(HaveOccurred()) defer f.Close() hash := sha1.New() _, err = io.Copy(hash, f) Expect(err).ToNot(HaveOccurred()) return fmt.Sprintf("%x", hash.Sum(nil)) }
[ "func", "Sha1Sum", "(", "path", "string", ")", "string", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "defer", "f", ".", "Close", "(", ")", "\n\n", "hash", ":=", "sha1", ".", "New", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "hash", ",", "f", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hash", ".", "Sum", "(", "nil", ")", ")", "\n", "}" ]
// Sha1Sum calculates the SHA1 sum of a file.
[ "Sha1Sum", "calculates", "the", "SHA1", "sum", "of", "a", "file", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/sha.go#L13-L23
train
cloudfoundry/cli
command/v6/push_command.go
GetCommandLineSettings
func (cmd PushCommand) GetCommandLineSettings() (pushaction.CommandLineSettings, error) { err := cmd.validateArgs() if err != nil { return pushaction.CommandLineSettings{}, err } pwd, err := os.Getwd() if err != nil { return pushaction.CommandLineSettings{}, err } dockerPassword := cmd.Config.DockerPassword() if dockerPassword != "" { cmd.UI.DisplayText("Using docker repository password from environment variable CF_DOCKER_PASSWORD.") } else if cmd.DockerUsername != "" { cmd.UI.DisplayText("Environment variable CF_DOCKER_PASSWORD not set.") dockerPassword, err = cmd.UI.DisplayPasswordPrompt("Docker password") if err != nil { return pushaction.CommandLineSettings{}, err } } config := pushaction.CommandLineSettings{ Buildpacks: cmd.Buildpacks, // -b Command: cmd.Command.FilteredString, // -c CurrentDirectory: pwd, DefaultRouteDomain: cmd.Domain, // -d DefaultRouteHostname: cmd.Hostname, // -n/--hostname DiskQuota: cmd.DiskQuota.Value, // -k DockerImage: cmd.DockerImage.Path, // -o DockerPassword: dockerPassword, // ENV - CF_DOCKER_PASSWORD DockerUsername: cmd.DockerUsername, // --docker-username DropletPath: string(cmd.DropletPath), // --droplet HealthCheckTimeout: cmd.HealthCheckTimeout, // -t HealthCheckType: cmd.HealthCheckType.Type, // -u/--health-check-type Instances: cmd.Instances.NullInt, // -i Memory: cmd.Memory.Value, // -m Name: cmd.OptionalArgs.AppName, // arg NoHostname: cmd.NoHostname, // --no-hostname NoRoute: cmd.NoRoute, // --no-route ProvidedAppPath: string(cmd.AppPath), // -p RandomRoute: cmd.RandomRoute, // --random-route RoutePath: cmd.RoutePath.Path, // --route-path StackName: cmd.StackName, // -s } log.Debugln("Command Line Settings:", config) return config, nil }
go
func (cmd PushCommand) GetCommandLineSettings() (pushaction.CommandLineSettings, error) { err := cmd.validateArgs() if err != nil { return pushaction.CommandLineSettings{}, err } pwd, err := os.Getwd() if err != nil { return pushaction.CommandLineSettings{}, err } dockerPassword := cmd.Config.DockerPassword() if dockerPassword != "" { cmd.UI.DisplayText("Using docker repository password from environment variable CF_DOCKER_PASSWORD.") } else if cmd.DockerUsername != "" { cmd.UI.DisplayText("Environment variable CF_DOCKER_PASSWORD not set.") dockerPassword, err = cmd.UI.DisplayPasswordPrompt("Docker password") if err != nil { return pushaction.CommandLineSettings{}, err } } config := pushaction.CommandLineSettings{ Buildpacks: cmd.Buildpacks, // -b Command: cmd.Command.FilteredString, // -c CurrentDirectory: pwd, DefaultRouteDomain: cmd.Domain, // -d DefaultRouteHostname: cmd.Hostname, // -n/--hostname DiskQuota: cmd.DiskQuota.Value, // -k DockerImage: cmd.DockerImage.Path, // -o DockerPassword: dockerPassword, // ENV - CF_DOCKER_PASSWORD DockerUsername: cmd.DockerUsername, // --docker-username DropletPath: string(cmd.DropletPath), // --droplet HealthCheckTimeout: cmd.HealthCheckTimeout, // -t HealthCheckType: cmd.HealthCheckType.Type, // -u/--health-check-type Instances: cmd.Instances.NullInt, // -i Memory: cmd.Memory.Value, // -m Name: cmd.OptionalArgs.AppName, // arg NoHostname: cmd.NoHostname, // --no-hostname NoRoute: cmd.NoRoute, // --no-route ProvidedAppPath: string(cmd.AppPath), // -p RandomRoute: cmd.RandomRoute, // --random-route RoutePath: cmd.RoutePath.Path, // --route-path StackName: cmd.StackName, // -s } log.Debugln("Command Line Settings:", config) return config, nil }
[ "func", "(", "cmd", "PushCommand", ")", "GetCommandLineSettings", "(", ")", "(", "pushaction", ".", "CommandLineSettings", ",", "error", ")", "{", "err", ":=", "cmd", ".", "validateArgs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "pushaction", ".", "CommandLineSettings", "{", "}", ",", "err", "\n", "}", "\n\n", "pwd", ",", "err", ":=", "os", ".", "Getwd", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "pushaction", ".", "CommandLineSettings", "{", "}", ",", "err", "\n", "}", "\n\n", "dockerPassword", ":=", "cmd", ".", "Config", ".", "DockerPassword", "(", ")", "\n", "if", "dockerPassword", "!=", "\"", "\"", "{", "cmd", ".", "UI", ".", "DisplayText", "(", "\"", "\"", ")", "\n", "}", "else", "if", "cmd", ".", "DockerUsername", "!=", "\"", "\"", "{", "cmd", ".", "UI", ".", "DisplayText", "(", "\"", "\"", ")", "\n", "dockerPassword", ",", "err", "=", "cmd", ".", "UI", ".", "DisplayPasswordPrompt", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "pushaction", ".", "CommandLineSettings", "{", "}", ",", "err", "\n", "}", "\n", "}", "\n\n", "config", ":=", "pushaction", ".", "CommandLineSettings", "{", "Buildpacks", ":", "cmd", ".", "Buildpacks", ",", "// -b", "Command", ":", "cmd", ".", "Command", ".", "FilteredString", ",", "// -c", "CurrentDirectory", ":", "pwd", ",", "DefaultRouteDomain", ":", "cmd", ".", "Domain", ",", "// -d", "DefaultRouteHostname", ":", "cmd", ".", "Hostname", ",", "// -n/--hostname", "DiskQuota", ":", "cmd", ".", "DiskQuota", ".", "Value", ",", "// -k", "DockerImage", ":", "cmd", ".", "DockerImage", ".", "Path", ",", "// -o", "DockerPassword", ":", "dockerPassword", ",", "// ENV - CF_DOCKER_PASSWORD", "DockerUsername", ":", "cmd", ".", "DockerUsername", ",", "// --docker-username", "DropletPath", ":", "string", "(", "cmd", ".", "DropletPath", ")", ",", "// --droplet", "HealthCheckTimeout", ":", "cmd", ".", "HealthCheckTimeout", ",", "// -t", "HealthCheckType", ":", "cmd", ".", "HealthCheckType", ".", "Type", ",", "// -u/--health-check-type", "Instances", ":", "cmd", ".", "Instances", ".", "NullInt", ",", "// -i", "Memory", ":", "cmd", ".", "Memory", ".", "Value", ",", "// -m", "Name", ":", "cmd", ".", "OptionalArgs", ".", "AppName", ",", "// arg", "NoHostname", ":", "cmd", ".", "NoHostname", ",", "// --no-hostname", "NoRoute", ":", "cmd", ".", "NoRoute", ",", "// --no-route", "ProvidedAppPath", ":", "string", "(", "cmd", ".", "AppPath", ")", ",", "// -p", "RandomRoute", ":", "cmd", ".", "RandomRoute", ",", "// --random-route", "RoutePath", ":", "cmd", ".", "RoutePath", ".", "Path", ",", "// --route-path", "StackName", ":", "cmd", ".", "StackName", ",", "// -s", "}", "\n\n", "log", ".", "Debugln", "(", "\"", "\"", ",", "config", ")", "\n", "return", "config", ",", "nil", "\n", "}" ]
// GetCommandLineSettings generates a push CommandLineSettings object from the // command's command line flags. It also validates those settings, preventing // contradictory flags.
[ "GetCommandLineSettings", "generates", "a", "push", "CommandLineSettings", "object", "from", "the", "command", "s", "command", "line", "flags", ".", "It", "also", "validates", "those", "settings", "preventing", "contradictory", "flags", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/push_command.go#L227-L275
train
cloudfoundry/cli
command/v6/shared/noaa_client.go
NewNOAAClient
func NewNOAAClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) *consumer.Consumer { client := consumer.New( apiURL, &tls.Config{ InsecureSkipVerify: config.SkipSSLValidation(), }, http.ProxyFromEnvironment, ) client.RefreshTokenFrom(noaabridge.NewTokenRefresher(uaaClient, config)) client.SetMaxRetryCount(config.NOAARequestRetryCount()) noaaDebugPrinter := DebugPrinter{} // if verbose, set debug printer on noaa client verbose, location := config.Verbose() client.SetDebugPrinter(&noaaDebugPrinter) if verbose { noaaDebugPrinter.addOutput(ui.RequestLoggerTerminalDisplay()) } if location != nil { noaaDebugPrinter.addOutput(ui.RequestLoggerFileWriter(location)) } return client }
go
func NewNOAAClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) *consumer.Consumer { client := consumer.New( apiURL, &tls.Config{ InsecureSkipVerify: config.SkipSSLValidation(), }, http.ProxyFromEnvironment, ) client.RefreshTokenFrom(noaabridge.NewTokenRefresher(uaaClient, config)) client.SetMaxRetryCount(config.NOAARequestRetryCount()) noaaDebugPrinter := DebugPrinter{} // if verbose, set debug printer on noaa client verbose, location := config.Verbose() client.SetDebugPrinter(&noaaDebugPrinter) if verbose { noaaDebugPrinter.addOutput(ui.RequestLoggerTerminalDisplay()) } if location != nil { noaaDebugPrinter.addOutput(ui.RequestLoggerFileWriter(location)) } return client }
[ "func", "NewNOAAClient", "(", "apiURL", "string", ",", "config", "command", ".", "Config", ",", "uaaClient", "*", "uaa", ".", "Client", ",", "ui", "command", ".", "UI", ")", "*", "consumer", ".", "Consumer", "{", "client", ":=", "consumer", ".", "New", "(", "apiURL", ",", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "config", ".", "SkipSSLValidation", "(", ")", ",", "}", ",", "http", ".", "ProxyFromEnvironment", ",", ")", "\n", "client", ".", "RefreshTokenFrom", "(", "noaabridge", ".", "NewTokenRefresher", "(", "uaaClient", ",", "config", ")", ")", "\n", "client", ".", "SetMaxRetryCount", "(", "config", ".", "NOAARequestRetryCount", "(", ")", ")", "\n\n", "noaaDebugPrinter", ":=", "DebugPrinter", "{", "}", "\n\n", "// if verbose, set debug printer on noaa client", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n\n", "client", ".", "SetDebugPrinter", "(", "&", "noaaDebugPrinter", ")", "\n\n", "if", "verbose", "{", "noaaDebugPrinter", ".", "addOutput", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "noaaDebugPrinter", ".", "addOutput", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", "\n", "}", "\n\n", "return", "client", "\n", "}" ]
// NewNOAAClient returns back a configured NOAA Client.
[ "NewNOAAClient", "returns", "back", "a", "configured", "NOAA", "Client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/noaa_client.go#L41-L67
train
cloudfoundry/cli
api/uaa/error_converter.go
Wrap
func (e *errorWrapper) Wrap(innerconnection Connection) Connection { e.connection = innerconnection return e }
go
func (e *errorWrapper) Wrap(innerconnection Connection) Connection { e.connection = innerconnection return e }
[ "func", "(", "e", "*", "errorWrapper", ")", "Wrap", "(", "innerconnection", "Connection", ")", "Connection", "{", "e", ".", "connection", "=", "innerconnection", "\n", "return", "e", "\n", "}" ]
// Wrap wraps a UAA connection in this error handling wrapper.
[ "Wrap", "wraps", "a", "UAA", "connection", "in", "this", "error", "handling", "wrapper", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/error_converter.go#L32-L35
train
cloudfoundry/cli
integration/helpers/reporters.go
WriteFailureSummary
func WriteFailureSummary(outputRoot, filename string) { outfile, err := os.Create(filepath.Join(outputRoot, filename)) failureSummaries := make([]string, 0) if err != nil { panic(err) } err = filepath.Walk(outputRoot, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { return nil } if strings.Contains(path, "summary") { return nil } defer os.Remove(path) allFailures, err := ioutil.ReadFile(path) if err != nil { return err } failures := strings.Split(string(allFailures), "\n") failureSummaries = append(failureSummaries, failures...) return nil }) if err != nil { panic(err) } sort.Strings(failureSummaries) anyFailures := false var previousLine string for _, line := range failureSummaries { if line != "" && line != previousLine { anyFailures = true previousLine = line fmt.Fprintln(outfile, line) } } if !anyFailures { err = os.Remove(filepath.Join(outputRoot, filename)) } if err != nil { panic(err) } }
go
func WriteFailureSummary(outputRoot, filename string) { outfile, err := os.Create(filepath.Join(outputRoot, filename)) failureSummaries := make([]string, 0) if err != nil { panic(err) } err = filepath.Walk(outputRoot, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if info.IsDir() { return nil } if strings.Contains(path, "summary") { return nil } defer os.Remove(path) allFailures, err := ioutil.ReadFile(path) if err != nil { return err } failures := strings.Split(string(allFailures), "\n") failureSummaries = append(failureSummaries, failures...) return nil }) if err != nil { panic(err) } sort.Strings(failureSummaries) anyFailures := false var previousLine string for _, line := range failureSummaries { if line != "" && line != previousLine { anyFailures = true previousLine = line fmt.Fprintln(outfile, line) } } if !anyFailures { err = os.Remove(filepath.Join(outputRoot, filename)) } if err != nil { panic(err) } }
[ "func", "WriteFailureSummary", "(", "outputRoot", ",", "filename", "string", ")", "{", "outfile", ",", "err", ":=", "os", ".", "Create", "(", "filepath", ".", "Join", "(", "outputRoot", ",", "filename", ")", ")", "\n", "failureSummaries", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "err", "=", "filepath", ".", "Walk", "(", "outputRoot", ",", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "info", ".", "IsDir", "(", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "strings", ".", "Contains", "(", "path", ",", "\"", "\"", ")", "{", "return", "nil", "\n", "}", "\n", "defer", "os", ".", "Remove", "(", "path", ")", "\n", "allFailures", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "failures", ":=", "strings", ".", "Split", "(", "string", "(", "allFailures", ")", ",", "\"", "\\n", "\"", ")", "\n", "failureSummaries", "=", "append", "(", "failureSummaries", ",", "failures", "...", ")", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "failureSummaries", ")", "\n", "anyFailures", ":=", "false", "\n", "var", "previousLine", "string", "\n", "for", "_", ",", "line", ":=", "range", "failureSummaries", "{", "if", "line", "!=", "\"", "\"", "&&", "line", "!=", "previousLine", "{", "anyFailures", "=", "true", "\n", "previousLine", "=", "line", "\n", "fmt", ".", "Fprintln", "(", "outfile", ",", "line", ")", "\n", "}", "\n", "}", "\n", "if", "!", "anyFailures", "{", "err", "=", "os", ".", "Remove", "(", "filepath", ".", "Join", "(", "outputRoot", ",", "filename", ")", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "}" ]
// WriteFailureSummary aggregates test failures from all parallel nodes, sorts // them, and writes the result to a file.
[ "WriteFailureSummary", "aggregates", "test", "failures", "from", "all", "parallel", "nodes", "sorts", "them", "and", "writes", "the", "result", "to", "a", "file", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/reporters.go#L61-L107
train
cloudfoundry/cli
cf/terminal/ui.go
Print
func (u *UITable) Print() error { result := &bytes.Buffer{} t := u.Table err := t.PrintTo(result) if err != nil { return err } // DevNote. With the change to printing into a buffer all // lines now come with a terminating \n. The t.ui.Say() below // will then add another \n to that. To avoid this additional // line we chop off the last \n from the output (if there is // any). Operating on the slice avoids string copying. // // WIBNI if the terminal API had a variant of Say not assuming // that each output is a single line. r := result.Bytes() if len(r) > 0 { r = r[0 : len(r)-1] } // Only generate output for a non-empty table. if len(r) > 0 { u.UI.Say("%s", string(r)) } return nil }
go
func (u *UITable) Print() error { result := &bytes.Buffer{} t := u.Table err := t.PrintTo(result) if err != nil { return err } // DevNote. With the change to printing into a buffer all // lines now come with a terminating \n. The t.ui.Say() below // will then add another \n to that. To avoid this additional // line we chop off the last \n from the output (if there is // any). Operating on the slice avoids string copying. // // WIBNI if the terminal API had a variant of Say not assuming // that each output is a single line. r := result.Bytes() if len(r) > 0 { r = r[0 : len(r)-1] } // Only generate output for a non-empty table. if len(r) > 0 { u.UI.Say("%s", string(r)) } return nil }
[ "func", "(", "u", "*", "UITable", ")", "Print", "(", ")", "error", "{", "result", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "t", ":=", "u", ".", "Table", "\n\n", "err", ":=", "t", ".", "PrintTo", "(", "result", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// DevNote. With the change to printing into a buffer all", "// lines now come with a terminating \\n. The t.ui.Say() below", "// will then add another \\n to that. To avoid this additional", "// line we chop off the last \\n from the output (if there is", "// any). Operating on the slice avoids string copying.", "//", "// WIBNI if the terminal API had a variant of Say not assuming", "// that each output is a single line.", "r", ":=", "result", ".", "Bytes", "(", ")", "\n", "if", "len", "(", "r", ")", ">", "0", "{", "r", "=", "r", "[", "0", ":", "len", "(", "r", ")", "-", "1", "]", "\n", "}", "\n\n", "// Only generate output for a non-empty table.", "if", "len", "(", "r", ")", ">", "0", "{", "u", ".", "UI", ".", "Say", "(", "\"", "\"", ",", "string", "(", "r", ")", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Print formats the table and then prints it to the UI specified at // the time of the construction. Afterwards the table is cleared, // becoming ready for another round of rows and printing.
[ "Print", "formats", "the", "table", "and", "then", "prints", "it", "to", "the", "UI", "specified", "at", "the", "time", "of", "the", "construction", ".", "Afterwards", "the", "table", "is", "cleared", "becoming", "ready", "for", "another", "round", "of", "rows", "and", "printing", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui.go#L272-L300
train
cloudfoundry/cli
actor/v2action/stack.go
GetStack
func (actor Actor) GetStack(guid string) (Stack, Warnings, error) { stack, warnings, err := actor.CloudControllerClient.GetStack(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{GUID: guid} } return Stack(stack), Warnings(warnings), err }
go
func (actor Actor) GetStack(guid string) (Stack, Warnings, error) { stack, warnings, err := actor.CloudControllerClient.GetStack(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{GUID: guid} } return Stack(stack), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetStack", "(", "guid", "string", ")", "(", "Stack", ",", "Warnings", ",", "error", ")", "{", "stack", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetStack", "(", "guid", ")", "\n\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "ok", "{", "return", "Stack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "StackNotFoundError", "{", "GUID", ":", "guid", "}", "\n", "}", "\n\n", "return", "Stack", "(", "stack", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetStack returns the stack information associated with the provided stack GUID.
[ "GetStack", "returns", "the", "stack", "information", "associated", "with", "the", "provided", "stack", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/stack.go#L13-L21
train
cloudfoundry/cli
actor/v2action/stack.go
GetStackByName
func (actor Actor) GetStackByName(stackName string) (Stack, Warnings, error) { stacks, warnings, err := actor.CloudControllerClient.GetStacks(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{stackName}, }) if err != nil { return Stack{}, Warnings(warnings), err } if len(stacks) == 0 { return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{Name: stackName} } return Stack(stacks[0]), Warnings(warnings), nil }
go
func (actor Actor) GetStackByName(stackName string) (Stack, Warnings, error) { stacks, warnings, err := actor.CloudControllerClient.GetStacks(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{stackName}, }) if err != nil { return Stack{}, Warnings(warnings), err } if len(stacks) == 0 { return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{Name: stackName} } return Stack(stacks[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetStackByName", "(", "stackName", "string", ")", "(", "Stack", ",", "Warnings", ",", "error", ")", "{", "stacks", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetStacks", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "stackName", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Stack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "stacks", ")", "==", "0", "{", "return", "Stack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "StackNotFoundError", "{", "Name", ":", "stackName", "}", "\n", "}", "\n\n", "return", "Stack", "(", "stacks", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetStackByName returns the provided stack
[ "GetStackByName", "returns", "the", "provided", "stack" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/stack.go#L24-L39
train
cloudfoundry/cli
api/cloudcontroller/ccv2/job.go
UnmarshalJSON
func (job *Job) UnmarshalJSON(data []byte) error { var ccJob struct { Entity struct { Error string `json:"error"` ErrorDetails struct { Description string `json:"description"` } `json:"error_details"` GUID string `json:"guid"` Status string `json:"status"` } `json:"entity"` Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccJob) if err != nil { return err } job.Error = ccJob.Entity.Error job.ErrorDetails.Description = ccJob.Entity.ErrorDetails.Description job.GUID = ccJob.Entity.GUID job.Status = constant.JobStatus(ccJob.Entity.Status) return nil }
go
func (job *Job) UnmarshalJSON(data []byte) error { var ccJob struct { Entity struct { Error string `json:"error"` ErrorDetails struct { Description string `json:"description"` } `json:"error_details"` GUID string `json:"guid"` Status string `json:"status"` } `json:"entity"` Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccJob) if err != nil { return err } job.Error = ccJob.Entity.Error job.ErrorDetails.Description = ccJob.Entity.ErrorDetails.Description job.GUID = ccJob.Entity.GUID job.Status = constant.JobStatus(ccJob.Entity.Status) return nil }
[ "func", "(", "job", "*", "Job", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccJob", "struct", "{", "Entity", "struct", "{", "Error", "string", "`json:\"error\"`", "\n", "ErrorDetails", "struct", "{", "Description", "string", "`json:\"description\"`", "\n", "}", "`json:\"error_details\"`", "\n", "GUID", "string", "`json:\"guid\"`", "\n", "Status", "string", "`json:\"status\"`", "\n", "}", "`json:\"entity\"`", "\n", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccJob", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "job", ".", "Error", "=", "ccJob", ".", "Entity", ".", "Error", "\n", "job", ".", "ErrorDetails", ".", "Description", "=", "ccJob", ".", "Entity", ".", "ErrorDetails", ".", "Description", "\n", "job", ".", "GUID", "=", "ccJob", ".", "Entity", ".", "GUID", "\n", "job", ".", "Status", "=", "constant", ".", "JobStatus", "(", "ccJob", ".", "Entity", ".", "Status", ")", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Job response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Job", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L54-L76
train
cloudfoundry/cli
api/cloudcontroller/ccv2/job.go
UploadDroplet
func (client *Client) UploadDroplet(appGUID string, droplet io.Reader, dropletLength int64) (Job, Warnings, error) { contentLength, err := client.calculateDropletRequestSize(dropletLength) if err != nil { return Job{}, nil, err } contentType, body, writeErrors := client.createMultipartBodyAndHeaderForDroplet(droplet) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutDropletRequest, URIParams: Params{"app_guid": appGUID}, Body: body, }) if err != nil { return Job{}, nil, err } request.Header.Set("Content-Type", contentType) request.ContentLength = contentLength return client.uploadAsynchronously(request, writeErrors) }
go
func (client *Client) UploadDroplet(appGUID string, droplet io.Reader, dropletLength int64) (Job, Warnings, error) { contentLength, err := client.calculateDropletRequestSize(dropletLength) if err != nil { return Job{}, nil, err } contentType, body, writeErrors := client.createMultipartBodyAndHeaderForDroplet(droplet) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutDropletRequest, URIParams: Params{"app_guid": appGUID}, Body: body, }) if err != nil { return Job{}, nil, err } request.Header.Set("Content-Type", contentType) request.ContentLength = contentLength return client.uploadAsynchronously(request, writeErrors) }
[ "func", "(", "client", "*", "Client", ")", "UploadDroplet", "(", "appGUID", "string", ",", "droplet", "io", ".", "Reader", ",", "dropletLength", "int64", ")", "(", "Job", ",", "Warnings", ",", "error", ")", "{", "contentLength", ",", "err", ":=", "client", ".", "calculateDropletRequestSize", "(", "dropletLength", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Job", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "contentType", ",", "body", ",", "writeErrors", ":=", "client", ".", "createMultipartBodyAndHeaderForDroplet", "(", "droplet", ")", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutDropletRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "appGUID", "}", ",", "Body", ":", "body", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Job", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "contentType", ")", "\n", "request", ".", "ContentLength", "=", "contentLength", "\n\n", "return", "client", ".", "uploadAsynchronously", "(", "request", ",", "writeErrors", ")", "\n", "}" ]
// UploadDroplet defines and uploads a previously staged droplet that an // application will run, using a multipart PUT request. The uploaded file // should be a gzipped tar file.
[ "UploadDroplet", "defines", "and", "uploads", "a", "previously", "staged", "droplet", "that", "an", "application", "will", "run", "using", "a", "multipart", "PUT", "request", ".", "The", "uploaded", "file", "should", "be", "a", "gzipped", "tar", "file", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L209-L230
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process_instance.go
UnmarshalJSON
func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { var inputInstance struct { Details string `json:"details"` DiskQuota uint64 `json:"disk_quota"` Index int64 `json:"index"` IsolationSegment string `json:"isolation_segment"` MemQuota uint64 `json:"mem_quota"` State string `json:"state"` Type string `json:"type"` Uptime int64 `json:"uptime"` Usage struct { CPU float64 `json:"cpu"` Mem uint64 `json:"mem"` Disk uint64 `json:"disk"` } `json:"usage"` } err := cloudcontroller.DecodeJSON(data, &inputInstance) if err != nil { return err } instance.CPU = inputInstance.Usage.CPU instance.Details = inputInstance.Details instance.DiskQuota = inputInstance.DiskQuota instance.DiskUsage = inputInstance.Usage.Disk instance.Index = inputInstance.Index instance.IsolationSegment = inputInstance.IsolationSegment instance.MemoryQuota = inputInstance.MemQuota instance.MemoryUsage = inputInstance.Usage.Mem instance.State = constant.ProcessInstanceState(inputInstance.State) instance.Type = inputInstance.Type instance.Uptime, err = time.ParseDuration(fmt.Sprintf("%ds", inputInstance.Uptime)) if err != nil { return err } return nil }
go
func (instance *ProcessInstance) UnmarshalJSON(data []byte) error { var inputInstance struct { Details string `json:"details"` DiskQuota uint64 `json:"disk_quota"` Index int64 `json:"index"` IsolationSegment string `json:"isolation_segment"` MemQuota uint64 `json:"mem_quota"` State string `json:"state"` Type string `json:"type"` Uptime int64 `json:"uptime"` Usage struct { CPU float64 `json:"cpu"` Mem uint64 `json:"mem"` Disk uint64 `json:"disk"` } `json:"usage"` } err := cloudcontroller.DecodeJSON(data, &inputInstance) if err != nil { return err } instance.CPU = inputInstance.Usage.CPU instance.Details = inputInstance.Details instance.DiskQuota = inputInstance.DiskQuota instance.DiskUsage = inputInstance.Usage.Disk instance.Index = inputInstance.Index instance.IsolationSegment = inputInstance.IsolationSegment instance.MemoryQuota = inputInstance.MemQuota instance.MemoryUsage = inputInstance.Usage.Mem instance.State = constant.ProcessInstanceState(inputInstance.State) instance.Type = inputInstance.Type instance.Uptime, err = time.ParseDuration(fmt.Sprintf("%ds", inputInstance.Uptime)) if err != nil { return err } return nil }
[ "func", "(", "instance", "*", "ProcessInstance", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "inputInstance", "struct", "{", "Details", "string", "`json:\"details\"`", "\n", "DiskQuota", "uint64", "`json:\"disk_quota\"`", "\n", "Index", "int64", "`json:\"index\"`", "\n", "IsolationSegment", "string", "`json:\"isolation_segment\"`", "\n", "MemQuota", "uint64", "`json:\"mem_quota\"`", "\n", "State", "string", "`json:\"state\"`", "\n", "Type", "string", "`json:\"type\"`", "\n", "Uptime", "int64", "`json:\"uptime\"`", "\n", "Usage", "struct", "{", "CPU", "float64", "`json:\"cpu\"`", "\n", "Mem", "uint64", "`json:\"mem\"`", "\n", "Disk", "uint64", "`json:\"disk\"`", "\n", "}", "`json:\"usage\"`", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "inputInstance", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "instance", ".", "CPU", "=", "inputInstance", ".", "Usage", ".", "CPU", "\n", "instance", ".", "Details", "=", "inputInstance", ".", "Details", "\n", "instance", ".", "DiskQuota", "=", "inputInstance", ".", "DiskQuota", "\n", "instance", ".", "DiskUsage", "=", "inputInstance", ".", "Usage", ".", "Disk", "\n", "instance", ".", "Index", "=", "inputInstance", ".", "Index", "\n", "instance", ".", "IsolationSegment", "=", "inputInstance", ".", "IsolationSegment", "\n", "instance", ".", "MemoryQuota", "=", "inputInstance", ".", "MemQuota", "\n", "instance", ".", "MemoryUsage", "=", "inputInstance", ".", "Usage", ".", "Mem", "\n", "instance", ".", "State", "=", "constant", ".", "ProcessInstanceState", "(", "inputInstance", ".", "State", ")", "\n", "instance", ".", "Type", "=", "inputInstance", ".", "Type", "\n", "instance", ".", "Uptime", ",", "err", "=", "time", ".", "ParseDuration", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "inputInstance", ".", "Uptime", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a V3 Cloud Controller Instance response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "V3", "Cloud", "Controller", "Instance", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process_instance.go#L44-L82
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process_instance.go
GetProcessInstances
func (client *Client) GetProcessInstances(processGUID string) ([]ProcessInstance, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetProcessStatsRequest, URIParams: map[string]string{"process_guid": processGUID}, }) if err != nil { return nil, nil, err } var fullInstancesList []ProcessInstance warnings, err := client.paginate(request, ProcessInstance{}, func(item interface{}) error { if instance, ok := item.(ProcessInstance); ok { fullInstancesList = append(fullInstancesList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ProcessInstance{}, Unexpected: item, } } return nil }) return fullInstancesList, warnings, err }
go
func (client *Client) GetProcessInstances(processGUID string) ([]ProcessInstance, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetProcessStatsRequest, URIParams: map[string]string{"process_guid": processGUID}, }) if err != nil { return nil, nil, err } var fullInstancesList []ProcessInstance warnings, err := client.paginate(request, ProcessInstance{}, func(item interface{}) error { if instance, ok := item.(ProcessInstance); ok { fullInstancesList = append(fullInstancesList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ProcessInstance{}, Unexpected: item, } } return nil }) return fullInstancesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetProcessInstances", "(", "processGUID", "string", ")", "(", "[", "]", "ProcessInstance", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetProcessStatsRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "processGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullInstancesList", "[", "]", "ProcessInstance", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ProcessInstance", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "instance", ",", "ok", ":=", "item", ".", "(", "ProcessInstance", ")", ";", "ok", "{", "fullInstancesList", "=", "append", "(", "fullInstancesList", ",", "instance", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ProcessInstance", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullInstancesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetProcessInstances lists instance stats for a given process.
[ "GetProcessInstances", "lists", "instance", "stats", "for", "a", "given", "process", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process_instance.go#L106-L129
train
cloudfoundry/cli
actor/v3action/application.go
GetApplicationsByGUIDs
func (actor Actor) GetApplicationsByGUIDs(appGUIDs ...string) ([]Application, Warnings, error) { ccApps, warnings, err := actor.CloudControllerClient.GetApplications( ccv3.Query{Key: ccv3.GUIDFilter, Values: appGUIDs}, ) if err != nil { return []Application{}, Warnings(warnings), err } var apps []Application for _, ccApp := range ccApps { apps = append(apps, actor.convertCCToActorApplication(ccApp)) } return apps, Warnings(warnings), nil }
go
func (actor Actor) GetApplicationsByGUIDs(appGUIDs ...string) ([]Application, Warnings, error) { ccApps, warnings, err := actor.CloudControllerClient.GetApplications( ccv3.Query{Key: ccv3.GUIDFilter, Values: appGUIDs}, ) if err != nil { return []Application{}, Warnings(warnings), err } var apps []Application for _, ccApp := range ccApps { apps = append(apps, actor.convertCCToActorApplication(ccApp)) } return apps, Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetApplicationsByGUIDs", "(", "appGUIDs", "...", "string", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "ccApps", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplications", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "GUIDFilter", ",", "Values", ":", "appGUIDs", "}", ",", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "var", "apps", "[", "]", "Application", "\n", "for", "_", ",", "ccApp", ":=", "range", "ccApps", "{", "apps", "=", "append", "(", "apps", ",", "actor", ".", "convertCCToActorApplication", "(", "ccApp", ")", ")", "\n", "}", "\n", "return", "apps", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetApplicationsByGUIDs returns all applications with the provided GUIDs.
[ "GetApplicationsByGUIDs", "returns", "all", "applications", "with", "the", "provided", "GUIDs", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L87-L101
train
cloudfoundry/cli
actor/v3action/application.go
RestartApplication
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) return Warnings(warnings), err }
go
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "RestartApplication", "(", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationRestart", "(", "appGUID", ")", "\n\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// RestartApplication restarts an application.
[ "RestartApplication", "restarts", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L145-L149
train
cloudfoundry/cli
actor/v3action/application.go
UpdateApplication
func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) { ccApp := ccv3.Application{ GUID: app.GUID, StackName: app.StackName, LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
go
func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) { ccApp := ccv3.Application{ GUID: app.GUID, StackName: app.StackName, LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "UpdateApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "ccApp", ":=", "ccv3", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "StackName", ":", "app", ".", "StackName", ",", "LifecycleType", ":", "app", ".", "LifecycleType", ",", "LifecycleBuildpacks", ":", "app", ".", "LifecycleBuildpacks", ",", "}", "\n\n", "updatedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplication", "(", "ccApp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "return", "actor", ".", "convertCCToActorApplication", "(", "updatedApp", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// UpdateApplication updates the buildpacks on an application
[ "UpdateApplication", "updates", "the", "buildpacks", "on", "an", "application" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L182-L196
train
cloudfoundry/cli
api/router/wrapper/uaa_authentication.go
NewUAAAuthentication
func NewUAAAuthentication(client UAAClient, cache TokenCache) *UAAAuthentication { return &UAAAuthentication{ client: client, cache: cache, } }
go
func NewUAAAuthentication(client UAAClient, cache TokenCache) *UAAAuthentication { return &UAAAuthentication{ client: client, cache: cache, } }
[ "func", "NewUAAAuthentication", "(", "client", "UAAClient", ",", "cache", "TokenCache", ")", "*", "UAAAuthentication", "{", "return", "&", "UAAAuthentication", "{", "client", ":", "client", ",", "cache", ":", "cache", ",", "}", "\n", "}" ]
// NewUAAAuthentication returns a pointer to a UAAAuthentication wrapper with // the client and a token cache.
[ "NewUAAAuthentication", "returns", "a", "pointer", "to", "a", "UAAAuthentication", "wrapper", "with", "the", "client", "and", "a", "token", "cache", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/wrapper/uaa_authentication.go#L36-L41
train
cloudfoundry/cli
util/configv3/write_config.go
WriteConfig
func WriteConfig(c *Config) error { rawConfig, err := json.MarshalIndent(c.ConfigFile, "", " ") if err != nil { return err } dir := configDirectory() err = os.MkdirAll(dir, 0700) if err != nil { return err } // Developer Note: The following is untested! Change at your own risk. // Setup notifications of termination signals to channel sig, create a process to // watch for these signals so we can remove transient config temp files. sig := make(chan os.Signal, 10) signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, os.Interrupt) defer signal.Stop(sig) tempConfigFile, err := ioutil.TempFile(dir, "temp-config") if err != nil { return err } tempConfigFile.Close() tempConfigFileName := tempConfigFile.Name() go catchSignal(sig, tempConfigFileName) err = ioutil.WriteFile(tempConfigFileName, rawConfig, 0600) if err != nil { return err } return os.Rename(tempConfigFileName, ConfigFilePath()) }
go
func WriteConfig(c *Config) error { rawConfig, err := json.MarshalIndent(c.ConfigFile, "", " ") if err != nil { return err } dir := configDirectory() err = os.MkdirAll(dir, 0700) if err != nil { return err } // Developer Note: The following is untested! Change at your own risk. // Setup notifications of termination signals to channel sig, create a process to // watch for these signals so we can remove transient config temp files. sig := make(chan os.Signal, 10) signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, os.Interrupt) defer signal.Stop(sig) tempConfigFile, err := ioutil.TempFile(dir, "temp-config") if err != nil { return err } tempConfigFile.Close() tempConfigFileName := tempConfigFile.Name() go catchSignal(sig, tempConfigFileName) err = ioutil.WriteFile(tempConfigFileName, rawConfig, 0600) if err != nil { return err } return os.Rename(tempConfigFileName, ConfigFilePath()) }
[ "func", "WriteConfig", "(", "c", "*", "Config", ")", "error", "{", "rawConfig", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "c", ".", "ConfigFile", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "dir", ":=", "configDirectory", "(", ")", "\n", "err", "=", "os", ".", "MkdirAll", "(", "dir", ",", "0700", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Developer Note: The following is untested! Change at your own risk.", "// Setup notifications of termination signals to channel sig, create a process to", "// watch for these signals so we can remove transient config temp files.", "sig", ":=", "make", "(", "chan", "os", ".", "Signal", ",", "10", ")", "\n", "signal", ".", "Notify", "(", "sig", ",", "syscall", ".", "SIGHUP", ",", "syscall", ".", "SIGINT", ",", "syscall", ".", "SIGQUIT", ",", "syscall", ".", "SIGTERM", ",", "os", ".", "Interrupt", ")", "\n", "defer", "signal", ".", "Stop", "(", "sig", ")", "\n\n", "tempConfigFile", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "dir", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "tempConfigFile", ".", "Close", "(", ")", "\n", "tempConfigFileName", ":=", "tempConfigFile", ".", "Name", "(", ")", "\n\n", "go", "catchSignal", "(", "sig", ",", "tempConfigFileName", ")", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "tempConfigFileName", ",", "rawConfig", ",", "0600", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", "os", ".", "Rename", "(", "tempConfigFileName", ",", "ConfigFilePath", "(", ")", ")", "\n", "}" ]
// WriteConfig creates the .cf directory and then writes the config.json. The // location of .cf directory is written in the same way LoadConfig reads .cf // directory.
[ "WriteConfig", "creates", "the", ".", "cf", "directory", "and", "then", "writes", "the", "config", ".", "json", ".", "The", "location", "of", ".", "cf", "directory", "is", "written", "in", "the", "same", "way", "LoadConfig", "reads", ".", "cf", "directory", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/write_config.go#L14-L48
train
cloudfoundry/cli
actor/v3action/space.go
ResetSpaceIsolationSegment
func (actor Actor) ResetSpaceIsolationSegment(orgGUID string, spaceGUID string) (string, Warnings, error) { var allWarnings Warnings _, apiWarnings, err := actor.CloudControllerClient.UpdateSpaceIsolationSegmentRelationship(spaceGUID, "") allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } isoSegRelationship, apiWarnings, err := actor.CloudControllerClient.GetOrganizationDefaultIsolationSegment(orgGUID) allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } var isoSegName string if isoSegRelationship.GUID != "" { isolationSegment, apiWarnings, err := actor.CloudControllerClient.GetIsolationSegment(isoSegRelationship.GUID) allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } isoSegName = isolationSegment.Name } return isoSegName, allWarnings, nil }
go
func (actor Actor) ResetSpaceIsolationSegment(orgGUID string, spaceGUID string) (string, Warnings, error) { var allWarnings Warnings _, apiWarnings, err := actor.CloudControllerClient.UpdateSpaceIsolationSegmentRelationship(spaceGUID, "") allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } isoSegRelationship, apiWarnings, err := actor.CloudControllerClient.GetOrganizationDefaultIsolationSegment(orgGUID) allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } var isoSegName string if isoSegRelationship.GUID != "" { isolationSegment, apiWarnings, err := actor.CloudControllerClient.GetIsolationSegment(isoSegRelationship.GUID) allWarnings = append(allWarnings, apiWarnings...) if err != nil { return "", allWarnings, err } isoSegName = isolationSegment.Name } return isoSegName, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "ResetSpaceIsolationSegment", "(", "orgGUID", "string", ",", "spaceGUID", "string", ")", "(", "string", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n\n", "_", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateSpaceIsolationSegmentRelationship", "(", "spaceGUID", ",", "\"", "\"", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "apiWarnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "isoSegRelationship", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetOrganizationDefaultIsolationSegment", "(", "orgGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "apiWarnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "var", "isoSegName", "string", "\n", "if", "isoSegRelationship", ".", "GUID", "!=", "\"", "\"", "{", "isolationSegment", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetIsolationSegment", "(", "isoSegRelationship", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "apiWarnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "allWarnings", ",", "err", "\n", "}", "\n", "isoSegName", "=", "isolationSegment", ".", "Name", "\n", "}", "\n\n", "return", "isoSegName", ",", "allWarnings", ",", "nil", "\n", "}" ]
// ResetSpaceIsolationSegment disassociates a space from an isolation segment. // // If the space's organization has a default isolation segment, return its // name. Otherwise return the empty string.
[ "ResetSpaceIsolationSegment", "disassociates", "a", "space", "from", "an", "isolation", "segment", ".", "If", "the", "space", "s", "organization", "has", "a", "default", "isolation", "segment", "return", "its", "name", ".", "Otherwise", "return", "the", "empty", "string", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/space.go#L21-L47
train
cloudfoundry/cli
command/v6/shared/new_v3_based_clients.go
NewV3BasedClients
func NewV3BasedClients(config command.Config, ui command.UI, targetCF bool, minVersionV3 string) (*ccv3.Client, *uaa.Client, error) { ccWrappers := []ccv3.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := ccWrapper.NewUAAAuthentication(nil, config) ccWrappers = append(ccWrappers, authWrapper) ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount())) ccClient := ccv3.NewClient(ccv3.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), JobPollingTimeout: config.OverallPollingTimeout(), JobPollingInterval: config.PollingInterval(), Wrappers: ccWrappers, }) if !targetCF { return ccClient, nil, nil } if config.Target() == "" { return nil, nil, translatableerror.NoAPISetError{ BinaryName: config.BinaryName(), } } _, err := ccClient.TargetCF(ccv3.TargetSettings{ URL: config.Target(), SkipSSLValidation: config.SkipSSLValidation(), DialTimeout: config.DialTimeout(), }) if err != nil { return nil, nil, err } if minVersionV3 != "" { err = command.MinimumCCAPIVersionCheck(ccClient.CloudControllerAPIVersion(), minVersionV3) if err != nil { if _, ok := err.(translatableerror.MinimumCFAPIVersionNotMetError); ok { return nil, nil, translatableerror.V3V2SwitchError{} } return nil, nil, err } } if ccClient.UAA() == "" { return nil, nil, translatableerror.UAAEndpointNotFoundError{} } uaaClient := uaa.NewClient(config) if verbose { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(uaaClient, config) uaaClient.WrapConnection(uaaAuthWrapper) uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount())) err = uaaClient.SetupResources(ccClient.UAA()) if err != nil { return nil, nil, err } uaaAuthWrapper.SetClient(uaaClient) authWrapper.SetClient(uaaClient) return ccClient, uaaClient, nil }
go
func NewV3BasedClients(config command.Config, ui command.UI, targetCF bool, minVersionV3 string) (*ccv3.Client, *uaa.Client, error) { ccWrappers := []ccv3.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := ccWrapper.NewUAAAuthentication(nil, config) ccWrappers = append(ccWrappers, authWrapper) ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount())) ccClient := ccv3.NewClient(ccv3.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), JobPollingTimeout: config.OverallPollingTimeout(), JobPollingInterval: config.PollingInterval(), Wrappers: ccWrappers, }) if !targetCF { return ccClient, nil, nil } if config.Target() == "" { return nil, nil, translatableerror.NoAPISetError{ BinaryName: config.BinaryName(), } } _, err := ccClient.TargetCF(ccv3.TargetSettings{ URL: config.Target(), SkipSSLValidation: config.SkipSSLValidation(), DialTimeout: config.DialTimeout(), }) if err != nil { return nil, nil, err } if minVersionV3 != "" { err = command.MinimumCCAPIVersionCheck(ccClient.CloudControllerAPIVersion(), minVersionV3) if err != nil { if _, ok := err.(translatableerror.MinimumCFAPIVersionNotMetError); ok { return nil, nil, translatableerror.V3V2SwitchError{} } return nil, nil, err } } if ccClient.UAA() == "" { return nil, nil, translatableerror.UAAEndpointNotFoundError{} } uaaClient := uaa.NewClient(config) if verbose { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(uaaClient, config) uaaClient.WrapConnection(uaaAuthWrapper) uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount())) err = uaaClient.SetupResources(ccClient.UAA()) if err != nil { return nil, nil, err } uaaAuthWrapper.SetClient(uaaClient) authWrapper.SetClient(uaaClient) return ccClient, uaaClient, nil }
[ "func", "NewV3BasedClients", "(", "config", "command", ".", "Config", ",", "ui", "command", ".", "UI", ",", "targetCF", "bool", ",", "minVersionV3", "string", ")", "(", "*", "ccv3", ".", "Client", ",", "*", "uaa", ".", "Client", ",", "error", ")", "{", "ccWrappers", ":=", "[", "]", "ccv3", ".", "ConnectionWrapper", "{", "}", "\n\n", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n", "if", "verbose", "{", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "authWrapper", ":=", "ccWrapper", ".", "NewUAAAuthentication", "(", "nil", ",", "config", ")", "\n\n", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "authWrapper", ")", "\n", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "ccClient", ":=", "ccv3", ".", "NewClient", "(", "ccv3", ".", "Config", "{", "AppName", ":", "config", ".", "BinaryName", "(", ")", ",", "AppVersion", ":", "config", ".", "BinaryVersion", "(", ")", ",", "JobPollingTimeout", ":", "config", ".", "OverallPollingTimeout", "(", ")", ",", "JobPollingInterval", ":", "config", ".", "PollingInterval", "(", ")", ",", "Wrappers", ":", "ccWrappers", ",", "}", ")", "\n\n", "if", "!", "targetCF", "{", "return", "ccClient", ",", "nil", ",", "nil", "\n", "}", "\n\n", "if", "config", ".", "Target", "(", ")", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "translatableerror", ".", "NoAPISetError", "{", "BinaryName", ":", "config", ".", "BinaryName", "(", ")", ",", "}", "\n", "}", "\n\n", "_", ",", "err", ":=", "ccClient", ".", "TargetCF", "(", "ccv3", ".", "TargetSettings", "{", "URL", ":", "config", ".", "Target", "(", ")", ",", "SkipSSLValidation", ":", "config", ".", "SkipSSLValidation", "(", ")", ",", "DialTimeout", ":", "config", ".", "DialTimeout", "(", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "minVersionV3", "!=", "\"", "\"", "{", "err", "=", "command", ".", "MinimumCCAPIVersionCheck", "(", "ccClient", ".", "CloudControllerAPIVersion", "(", ")", ",", "minVersionV3", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "translatableerror", ".", "MinimumCFAPIVersionNotMetError", ")", ";", "ok", "{", "return", "nil", ",", "nil", ",", "translatableerror", ".", "V3V2SwitchError", "{", "}", "\n", "}", "\n", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "if", "ccClient", ".", "UAA", "(", ")", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "translatableerror", ".", "UAAEndpointNotFoundError", "{", "}", "\n", "}", "\n\n", "uaaClient", ":=", "uaa", ".", "NewClient", "(", "config", ")", "\n\n", "if", "verbose", "{", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "uaaAuthWrapper", ":=", "uaaWrapper", ".", "NewUAAAuthentication", "(", "uaaClient", ",", "config", ")", "\n", "uaaClient", ".", "WrapConnection", "(", "uaaAuthWrapper", ")", "\n", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "err", "=", "uaaClient", ".", "SetupResources", "(", "ccClient", ".", "UAA", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "uaaAuthWrapper", ".", "SetClient", "(", "uaaClient", ")", "\n", "authWrapper", ".", "SetClient", "(", "uaaClient", ")", "\n\n", "return", "ccClient", ",", "uaaClient", ",", "nil", "\n", "}" ]
// NewV3BasedClients creates a new V3 Cloud Controller client and UAA client using the // passed in config.
[ "NewV3BasedClients", "creates", "a", "new", "V3", "Cloud", "Controller", "client", "and", "UAA", "client", "using", "the", "passed", "in", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_v3_based_clients.go#L14-L93
train
cloudfoundry/cli
actor/v2action/service_broker.go
CreateServiceBroker
func (actor Actor) CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID string) (ServiceBroker, Warnings, error) { serviceBroker, warnings, err := actor.CloudControllerClient.CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID) return ServiceBroker(serviceBroker), Warnings(warnings), err }
go
func (actor Actor) CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID string) (ServiceBroker, Warnings, error) { serviceBroker, warnings, err := actor.CloudControllerClient.CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID) return ServiceBroker(serviceBroker), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "CreateServiceBroker", "(", "serviceBrokerName", ",", "username", ",", "password", ",", "brokerURI", ",", "spaceGUID", "string", ")", "(", "ServiceBroker", ",", "Warnings", ",", "error", ")", "{", "serviceBroker", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateServiceBroker", "(", "serviceBrokerName", ",", "username", ",", "password", ",", "brokerURI", ",", "spaceGUID", ")", "\n", "return", "ServiceBroker", "(", "serviceBroker", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// CreateServiceBroker returns a ServiceBroker and any warnings or errors.
[ "CreateServiceBroker", "returns", "a", "ServiceBroker", "and", "any", "warnings", "or", "errors", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L12-L15
train
cloudfoundry/cli
actor/v2action/service_broker.go
GetServiceBrokers
func (actor Actor) GetServiceBrokers() ([]ServiceBroker, Warnings, error) { brokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers() if err != nil { return nil, Warnings(warnings), err } var brokersToReturn []ServiceBroker for _, b := range brokers { brokersToReturn = append(brokersToReturn, ServiceBroker(b)) } return brokersToReturn, Warnings(warnings), nil }
go
func (actor Actor) GetServiceBrokers() ([]ServiceBroker, Warnings, error) { brokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers() if err != nil { return nil, Warnings(warnings), err } var brokersToReturn []ServiceBroker for _, b := range brokers { brokersToReturn = append(brokersToReturn, ServiceBroker(b)) } return brokersToReturn, Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetServiceBrokers", "(", ")", "(", "[", "]", "ServiceBroker", ",", "Warnings", ",", "error", ")", "{", "brokers", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServiceBrokers", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "var", "brokersToReturn", "[", "]", "ServiceBroker", "\n", "for", "_", ",", "b", ":=", "range", "brokers", "{", "brokersToReturn", "=", "append", "(", "brokersToReturn", ",", "ServiceBroker", "(", "b", ")", ")", "\n", "}", "\n\n", "return", "brokersToReturn", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetServiceBrokers returns all ServiceBrokers and any warnings or errors.
[ "GetServiceBrokers", "returns", "all", "ServiceBrokers", "and", "any", "warnings", "or", "errors", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L18-L30
train
cloudfoundry/cli
actor/v2action/service_broker.go
GetServiceBrokerByName
func (actor Actor) GetServiceBrokerByName(brokerName string) (ServiceBroker, Warnings, error) { serviceBrokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{brokerName}, }) if err != nil { return ServiceBroker{}, Warnings(warnings), err } if len(serviceBrokers) == 0 { return ServiceBroker{}, Warnings(warnings), actionerror.ServiceBrokerNotFoundError{Name: brokerName} } return ServiceBroker(serviceBrokers[0]), Warnings(warnings), err }
go
func (actor Actor) GetServiceBrokerByName(brokerName string) (ServiceBroker, Warnings, error) { serviceBrokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{brokerName}, }) if err != nil { return ServiceBroker{}, Warnings(warnings), err } if len(serviceBrokers) == 0 { return ServiceBroker{}, Warnings(warnings), actionerror.ServiceBrokerNotFoundError{Name: brokerName} } return ServiceBroker(serviceBrokers[0]), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetServiceBrokerByName", "(", "brokerName", "string", ")", "(", "ServiceBroker", ",", "Warnings", ",", "error", ")", "{", "serviceBrokers", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServiceBrokers", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "brokerName", "}", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "ServiceBroker", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "serviceBrokers", ")", "==", "0", "{", "return", "ServiceBroker", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ServiceBrokerNotFoundError", "{", "Name", ":", "brokerName", "}", "\n", "}", "\n\n", "return", "ServiceBroker", "(", "serviceBrokers", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetServiceBrokerByName returns a ServiceBroker and any warnings or errors.
[ "GetServiceBrokerByName", "returns", "a", "ServiceBroker", "and", "any", "warnings", "or", "errors", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L33-L49
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space_summary.go
UnmarshalJSON
func (spaceSummary *SpaceSummary) UnmarshalJSON(data []byte) error { var ccSpaceSummary struct { Applications []SpaceSummaryApplication `json:"apps"` Name string `json:"name"` ServiceInstances []SpaceSummaryServiceInstance `json:"services"` } err := cloudcontroller.DecodeJSON(data, &ccSpaceSummary) if err != nil { return err } spaceSummary.Name = ccSpaceSummary.Name spaceSummary.Applications = ccSpaceSummary.Applications spaceSummary.ServiceInstances = ccSpaceSummary.ServiceInstances return nil }
go
func (spaceSummary *SpaceSummary) UnmarshalJSON(data []byte) error { var ccSpaceSummary struct { Applications []SpaceSummaryApplication `json:"apps"` Name string `json:"name"` ServiceInstances []SpaceSummaryServiceInstance `json:"services"` } err := cloudcontroller.DecodeJSON(data, &ccSpaceSummary) if err != nil { return err } spaceSummary.Name = ccSpaceSummary.Name spaceSummary.Applications = ccSpaceSummary.Applications spaceSummary.ServiceInstances = ccSpaceSummary.ServiceInstances return nil }
[ "func", "(", "spaceSummary", "*", "SpaceSummary", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccSpaceSummary", "struct", "{", "Applications", "[", "]", "SpaceSummaryApplication", "`json:\"apps\"`", "\n", "Name", "string", "`json:\"name\"`", "\n", "ServiceInstances", "[", "]", "SpaceSummaryServiceInstance", "`json:\"services\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccSpaceSummary", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "spaceSummary", ".", "Name", "=", "ccSpaceSummary", ".", "Name", "\n", "spaceSummary", ".", "Applications", "=", "ccSpaceSummary", ".", "Applications", "\n", "spaceSummary", ".", "ServiceInstances", "=", "ccSpaceSummary", ".", "ServiceInstances", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Space Summary response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Space", "Summary", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space_summary.go#L43-L59
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space_summary.go
GetSpaceSummary
func (client *Client) GetSpaceSummary(spaceGUID string) (SpaceSummary, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceSummaryRequest, URIParams: Params{"space_guid": spaceGUID}, }) if err != nil { return SpaceSummary{}, nil, err } var spaceSummary SpaceSummary response := cloudcontroller.Response{ DecodeJSONResponseInto: &spaceSummary, } err = client.connection.Make(request, &response) return spaceSummary, response.Warnings, err }
go
func (client *Client) GetSpaceSummary(spaceGUID string) (SpaceSummary, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceSummaryRequest, URIParams: Params{"space_guid": spaceGUID}, }) if err != nil { return SpaceSummary{}, nil, err } var spaceSummary SpaceSummary response := cloudcontroller.Response{ DecodeJSONResponseInto: &spaceSummary, } err = client.connection.Make(request, &response) return spaceSummary, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceSummary", "(", "spaceGUID", "string", ")", "(", "SpaceSummary", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpaceSummaryRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "SpaceSummary", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "spaceSummary", "SpaceSummary", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "spaceSummary", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "spaceSummary", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetSpaceSummary returns the summary of the space with the given GUID.
[ "GetSpaceSummary", "returns", "the", "summary", "of", "the", "space", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space_summary.go#L62-L78
train
cloudfoundry/cli
command/v6/target_command.go
setOrg
func (cmd *TargetCommand) setOrg() error { org, warnings, err := cmd.Actor.GetOrganizationByName(cmd.Organization) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } cmd.Config.SetOrganizationInformation(org.GUID, cmd.Organization) cmd.Config.UnsetSpaceInformation() return nil }
go
func (cmd *TargetCommand) setOrg() error { org, warnings, err := cmd.Actor.GetOrganizationByName(cmd.Organization) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } cmd.Config.SetOrganizationInformation(org.GUID, cmd.Organization) cmd.Config.UnsetSpaceInformation() return nil }
[ "func", "(", "cmd", "*", "TargetCommand", ")", "setOrg", "(", ")", "error", "{", "org", ",", "warnings", ",", "err", ":=", "cmd", ".", "Actor", ".", "GetOrganizationByName", "(", "cmd", ".", "Organization", ")", "\n", "cmd", ".", "UI", ".", "DisplayWarnings", "(", "warnings", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "cmd", ".", "Config", ".", "SetOrganizationInformation", "(", "org", ".", "GUID", ",", "cmd", ".", "Organization", ")", "\n", "cmd", ".", "Config", ".", "UnsetSpaceInformation", "(", ")", "\n\n", "return", "nil", "\n", "}" ]
// setOrg sets organization
[ "setOrg", "sets", "organization" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L141-L152
train
cloudfoundry/cli
command/v6/target_command.go
autoTargetSpace
func (cmd *TargetCommand) autoTargetSpace(orgGUID string) error { spaces, warnings, err := cmd.Actor.GetOrganizationSpaces(orgGUID) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } if len(spaces) == 1 { space := spaces[0] cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH) } return nil }
go
func (cmd *TargetCommand) autoTargetSpace(orgGUID string) error { spaces, warnings, err := cmd.Actor.GetOrganizationSpaces(orgGUID) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } if len(spaces) == 1 { space := spaces[0] cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH) } return nil }
[ "func", "(", "cmd", "*", "TargetCommand", ")", "autoTargetSpace", "(", "orgGUID", "string", ")", "error", "{", "spaces", ",", "warnings", ",", "err", ":=", "cmd", ".", "Actor", ".", "GetOrganizationSpaces", "(", "orgGUID", ")", "\n", "cmd", ".", "UI", ".", "DisplayWarnings", "(", "warnings", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "len", "(", "spaces", ")", "==", "1", "{", "space", ":=", "spaces", "[", "0", "]", "\n", "cmd", ".", "Config", ".", "SetSpaceInformation", "(", "space", ".", "GUID", ",", "space", ".", "Name", ",", "space", ".", "AllowSSH", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// autoTargetSpace targets the space if there is only one space in the org // and no space arg was provided.
[ "autoTargetSpace", "targets", "the", "space", "if", "there", "is", "only", "one", "space", "in", "the", "org", "and", "no", "space", "arg", "was", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L156-L169
train
cloudfoundry/cli
command/v6/target_command.go
setSpace
func (cmd *TargetCommand) setSpace() error { if !cmd.Config.HasTargetedOrganization() { return translatableerror.NoOrganizationTargetedError{BinaryName: cmd.Config.BinaryName()} } space, warnings, err := cmd.Actor.GetSpaceByOrganizationAndName(cmd.Config.TargetedOrganization().GUID, cmd.Space) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH) return nil }
go
func (cmd *TargetCommand) setSpace() error { if !cmd.Config.HasTargetedOrganization() { return translatableerror.NoOrganizationTargetedError{BinaryName: cmd.Config.BinaryName()} } space, warnings, err := cmd.Actor.GetSpaceByOrganizationAndName(cmd.Config.TargetedOrganization().GUID, cmd.Space) cmd.UI.DisplayWarnings(warnings) if err != nil { return err } cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH) return nil }
[ "func", "(", "cmd", "*", "TargetCommand", ")", "setSpace", "(", ")", "error", "{", "if", "!", "cmd", ".", "Config", ".", "HasTargetedOrganization", "(", ")", "{", "return", "translatableerror", ".", "NoOrganizationTargetedError", "{", "BinaryName", ":", "cmd", ".", "Config", ".", "BinaryName", "(", ")", "}", "\n", "}", "\n\n", "space", ",", "warnings", ",", "err", ":=", "cmd", ".", "Actor", ".", "GetSpaceByOrganizationAndName", "(", "cmd", ".", "Config", ".", "TargetedOrganization", "(", ")", ".", "GUID", ",", "cmd", ".", "Space", ")", "\n", "cmd", ".", "UI", ".", "DisplayWarnings", "(", "warnings", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "cmd", ".", "Config", ".", "SetSpaceInformation", "(", "space", ".", "GUID", ",", "space", ".", "Name", ",", "space", ".", "AllowSSH", ")", "\n\n", "return", "nil", "\n", "}" ]
// setSpace sets space
[ "setSpace", "sets", "space" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L172-L186
train
cloudfoundry/cli
command/v6/target_command.go
displayTargetTable
func (cmd *TargetCommand) displayTargetTable(user configv3.User) { table := [][]string{ {cmd.UI.TranslateText("api endpoint:"), cmd.Config.Target()}, {cmd.UI.TranslateText("api version:"), cmd.Actor.CloudControllerAPIVersion()}, {cmd.UI.TranslateText("user:"), user.Name}, } if cmd.Config.HasTargetedOrganization() { table = append(table, []string{ cmd.UI.TranslateText("org:"), cmd.Config.TargetedOrganization().Name, }) } if cmd.Config.HasTargetedSpace() { table = append(table, []string{ cmd.UI.TranslateText("space:"), cmd.Config.TargetedSpace().Name, }) } cmd.UI.DisplayKeyValueTable("", table, 3) }
go
func (cmd *TargetCommand) displayTargetTable(user configv3.User) { table := [][]string{ {cmd.UI.TranslateText("api endpoint:"), cmd.Config.Target()}, {cmd.UI.TranslateText("api version:"), cmd.Actor.CloudControllerAPIVersion()}, {cmd.UI.TranslateText("user:"), user.Name}, } if cmd.Config.HasTargetedOrganization() { table = append(table, []string{ cmd.UI.TranslateText("org:"), cmd.Config.TargetedOrganization().Name, }) } if cmd.Config.HasTargetedSpace() { table = append(table, []string{ cmd.UI.TranslateText("space:"), cmd.Config.TargetedSpace().Name, }) } cmd.UI.DisplayKeyValueTable("", table, 3) }
[ "func", "(", "cmd", "*", "TargetCommand", ")", "displayTargetTable", "(", "user", "configv3", ".", "User", ")", "{", "table", ":=", "[", "]", "[", "]", "string", "{", "{", "cmd", ".", "UI", ".", "TranslateText", "(", "\"", "\"", ")", ",", "cmd", ".", "Config", ".", "Target", "(", ")", "}", ",", "{", "cmd", ".", "UI", ".", "TranslateText", "(", "\"", "\"", ")", ",", "cmd", ".", "Actor", ".", "CloudControllerAPIVersion", "(", ")", "}", ",", "{", "cmd", ".", "UI", ".", "TranslateText", "(", "\"", "\"", ")", ",", "user", ".", "Name", "}", ",", "}", "\n\n", "if", "cmd", ".", "Config", ".", "HasTargetedOrganization", "(", ")", "{", "table", "=", "append", "(", "table", ",", "[", "]", "string", "{", "cmd", ".", "UI", ".", "TranslateText", "(", "\"", "\"", ")", ",", "cmd", ".", "Config", ".", "TargetedOrganization", "(", ")", ".", "Name", ",", "}", ")", "\n", "}", "\n\n", "if", "cmd", ".", "Config", ".", "HasTargetedSpace", "(", ")", "{", "table", "=", "append", "(", "table", ",", "[", "]", "string", "{", "cmd", ".", "UI", ".", "TranslateText", "(", "\"", "\"", ")", ",", "cmd", ".", "Config", ".", "TargetedSpace", "(", ")", ".", "Name", ",", "}", ")", "\n", "}", "\n", "cmd", ".", "UI", ".", "DisplayKeyValueTable", "(", "\"", "\"", ",", "table", ",", "3", ")", "\n", "}" ]
// displayTargetTable neatly displays target information.
[ "displayTargetTable", "neatly", "displays", "target", "information", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L189-L208
train
cloudfoundry/cli
actor/actionerror/plugin_not_found_in_repository_error.go
Error
func (e PluginNotFoundInRepositoryError) Error() string { return fmt.Sprintf("Plugin %s not found in repository %s", e.PluginName, e.RepositoryName) }
go
func (e PluginNotFoundInRepositoryError) Error() string { return fmt.Sprintf("Plugin %s not found in repository %s", e.PluginName, e.RepositoryName) }
[ "func", "(", "e", "PluginNotFoundInRepositoryError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "PluginName", ",", "e", ".", "RepositoryName", ")", "\n", "}" ]
// Error outputs the plugin not found in repository error message.
[ "Error", "outputs", "the", "plugin", "not", "found", "in", "repository", "error", "message", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/actionerror/plugin_not_found_in_repository_error.go#L13-L15
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_plan.go
UnmarshalJSON
func (servicePlan *ServicePlan) UnmarshalJSON(data []byte) error { var ccServicePlan struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` ServiceGUID string `json:"service_guid"` Public bool `json:"public"` Description string `json:"description"` Free bool `json:"free"` } } err := cloudcontroller.DecodeJSON(data, &ccServicePlan) if err != nil { return err } servicePlan.GUID = ccServicePlan.Metadata.GUID servicePlan.Name = ccServicePlan.Entity.Name servicePlan.ServiceGUID = ccServicePlan.Entity.ServiceGUID servicePlan.Public = ccServicePlan.Entity.Public servicePlan.Description = ccServicePlan.Entity.Description servicePlan.Free = ccServicePlan.Entity.Free return nil }
go
func (servicePlan *ServicePlan) UnmarshalJSON(data []byte) error { var ccServicePlan struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` ServiceGUID string `json:"service_guid"` Public bool `json:"public"` Description string `json:"description"` Free bool `json:"free"` } } err := cloudcontroller.DecodeJSON(data, &ccServicePlan) if err != nil { return err } servicePlan.GUID = ccServicePlan.Metadata.GUID servicePlan.Name = ccServicePlan.Entity.Name servicePlan.ServiceGUID = ccServicePlan.Entity.ServiceGUID servicePlan.Public = ccServicePlan.Entity.Public servicePlan.Description = ccServicePlan.Entity.Description servicePlan.Free = ccServicePlan.Entity.Free return nil }
[ "func", "(", "servicePlan", "*", "ServicePlan", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccServicePlan", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "ServiceGUID", "string", "`json:\"service_guid\"`", "\n", "Public", "bool", "`json:\"public\"`", "\n", "Description", "string", "`json:\"description\"`", "\n", "Free", "bool", "`json:\"free\"`", "\n", "}", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccServicePlan", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "servicePlan", ".", "GUID", "=", "ccServicePlan", ".", "Metadata", ".", "GUID", "\n", "servicePlan", ".", "Name", "=", "ccServicePlan", ".", "Entity", ".", "Name", "\n", "servicePlan", ".", "ServiceGUID", "=", "ccServicePlan", ".", "Entity", ".", "ServiceGUID", "\n", "servicePlan", ".", "Public", "=", "ccServicePlan", ".", "Entity", ".", "Public", "\n", "servicePlan", ".", "Description", "=", "ccServicePlan", ".", "Entity", ".", "Description", "\n", "servicePlan", ".", "Free", "=", "ccServicePlan", ".", "Entity", ".", "Free", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service Plan response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "Plan", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_plan.go#L36-L59
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_plan.go
GetServicePlan
func (client *Client) GetServicePlan(servicePlanGUID string) (ServicePlan, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServicePlanRequest, URIParams: Params{"service_plan_guid": servicePlanGUID}, }) if err != nil { return ServicePlan{}, nil, err } var servicePlan ServicePlan response := cloudcontroller.Response{ DecodeJSONResponseInto: &servicePlan, } err = client.connection.Make(request, &response) return servicePlan, response.Warnings, err }
go
func (client *Client) GetServicePlan(servicePlanGUID string) (ServicePlan, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServicePlanRequest, URIParams: Params{"service_plan_guid": servicePlanGUID}, }) if err != nil { return ServicePlan{}, nil, err } var servicePlan ServicePlan response := cloudcontroller.Response{ DecodeJSONResponseInto: &servicePlan, } err = client.connection.Make(request, &response) return servicePlan, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServicePlan", "(", "servicePlanGUID", "string", ")", "(", "ServicePlan", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServicePlanRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "servicePlanGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServicePlan", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "servicePlan", "ServicePlan", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "servicePlan", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "servicePlan", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetServicePlan returns the service plan with the given GUID.
[ "GetServicePlan", "returns", "the", "service", "plan", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_plan.go#L62-L78
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
CreateIsolationSegmentByName
func (actor Actor) CreateIsolationSegmentByName(isolationSegment IsolationSegment) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.CreateIsolationSegment(ccv3.IsolationSegment(isolationSegment)) if _, ok := err.(ccerror.UnprocessableEntityError); ok { return Warnings(warnings), actionerror.IsolationSegmentAlreadyExistsError{Name: isolationSegment.Name} } return Warnings(warnings), err }
go
func (actor Actor) CreateIsolationSegmentByName(isolationSegment IsolationSegment) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.CreateIsolationSegment(ccv3.IsolationSegment(isolationSegment)) if _, ok := err.(ccerror.UnprocessableEntityError); ok { return Warnings(warnings), actionerror.IsolationSegmentAlreadyExistsError{Name: isolationSegment.Name} } return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "CreateIsolationSegmentByName", "(", "isolationSegment", "IsolationSegment", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateIsolationSegment", "(", "ccv3", ".", "IsolationSegment", "(", "isolationSegment", ")", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "UnprocessableEntityError", ")", ";", "ok", "{", "return", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "IsolationSegmentAlreadyExistsError", "{", "Name", ":", "isolationSegment", ".", "Name", "}", "\n", "}", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// CreateIsolationSegmentByName creates a given isolation segment.
[ "CreateIsolationSegmentByName", "creates", "a", "given", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L53-L59
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
DeleteIsolationSegmentByName
func (actor Actor) DeleteIsolationSegmentByName(name string) (Warnings, error) { isolationSegment, warnings, err := actor.GetIsolationSegmentByName(name) allWarnings := append(Warnings{}, warnings...) if err != nil { return allWarnings, err } apiWarnings, err := actor.CloudControllerClient.DeleteIsolationSegment(isolationSegment.GUID) return append(allWarnings, apiWarnings...), err }
go
func (actor Actor) DeleteIsolationSegmentByName(name string) (Warnings, error) { isolationSegment, warnings, err := actor.GetIsolationSegmentByName(name) allWarnings := append(Warnings{}, warnings...) if err != nil { return allWarnings, err } apiWarnings, err := actor.CloudControllerClient.DeleteIsolationSegment(isolationSegment.GUID) return append(allWarnings, apiWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "DeleteIsolationSegmentByName", "(", "name", "string", ")", "(", "Warnings", ",", "error", ")", "{", "isolationSegment", ",", "warnings", ",", "err", ":=", "actor", ".", "GetIsolationSegmentByName", "(", "name", ")", "\n", "allWarnings", ":=", "append", "(", "Warnings", "{", "}", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n\n", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "DeleteIsolationSegment", "(", "isolationSegment", ".", "GUID", ")", "\n", "return", "append", "(", "allWarnings", ",", "apiWarnings", "...", ")", ",", "err", "\n", "}" ]
// DeleteIsolationSegmentByName deletes the given isolation segment.
[ "DeleteIsolationSegmentByName", "deletes", "the", "given", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L62-L71
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
EntitleIsolationSegmentToOrganizationByName
func (actor Actor) EntitleIsolationSegmentToOrganizationByName(isolationSegmentName string, orgName string) (Warnings, error) { isolationSegment, warnings, err := actor.GetIsolationSegmentByName(isolationSegmentName) allWarnings := append(Warnings{}, warnings...) if err != nil { return allWarnings, err } organization, warnings, err := actor.GetOrganizationByName(orgName) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } _, apiWarnings, err := actor.CloudControllerClient.EntitleIsolationSegmentToOrganizations(isolationSegment.GUID, []string{organization.GUID}) return append(allWarnings, apiWarnings...), err }
go
func (actor Actor) EntitleIsolationSegmentToOrganizationByName(isolationSegmentName string, orgName string) (Warnings, error) { isolationSegment, warnings, err := actor.GetIsolationSegmentByName(isolationSegmentName) allWarnings := append(Warnings{}, warnings...) if err != nil { return allWarnings, err } organization, warnings, err := actor.GetOrganizationByName(orgName) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } _, apiWarnings, err := actor.CloudControllerClient.EntitleIsolationSegmentToOrganizations(isolationSegment.GUID, []string{organization.GUID}) return append(allWarnings, apiWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "EntitleIsolationSegmentToOrganizationByName", "(", "isolationSegmentName", "string", ",", "orgName", "string", ")", "(", "Warnings", ",", "error", ")", "{", "isolationSegment", ",", "warnings", ",", "err", ":=", "actor", ".", "GetIsolationSegmentByName", "(", "isolationSegmentName", ")", "\n", "allWarnings", ":=", "append", "(", "Warnings", "{", "}", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n\n", "organization", ",", "warnings", ",", "err", ":=", "actor", ".", "GetOrganizationByName", "(", "orgName", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n\n", "_", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "EntitleIsolationSegmentToOrganizations", "(", "isolationSegment", ".", "GUID", ",", "[", "]", "string", "{", "organization", ".", "GUID", "}", ")", "\n", "return", "append", "(", "allWarnings", ",", "apiWarnings", "...", ")", ",", "err", "\n", "}" ]
// EntitleIsolationSegmentToOrganizationByName entitles the given organization // to use the specified isolation segment
[ "EntitleIsolationSegmentToOrganizationByName", "entitles", "the", "given", "organization", "to", "use", "the", "specified", "isolation", "segment" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L75-L90
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
GetIsolationSegmentByName
func (actor Actor) GetIsolationSegmentByName(name string) (IsolationSegment, Warnings, error) { isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, ) if err != nil { return IsolationSegment{}, Warnings(warnings), err } if len(isolationSegments) == 0 { return IsolationSegment{}, Warnings(warnings), actionerror.IsolationSegmentNotFoundError{Name: name} } return IsolationSegment(isolationSegments[0]), Warnings(warnings), nil }
go
func (actor Actor) GetIsolationSegmentByName(name string) (IsolationSegment, Warnings, error) { isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, ) if err != nil { return IsolationSegment{}, Warnings(warnings), err } if len(isolationSegments) == 0 { return IsolationSegment{}, Warnings(warnings), actionerror.IsolationSegmentNotFoundError{Name: name} } return IsolationSegment(isolationSegments[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetIsolationSegmentByName", "(", "name", "string", ")", "(", "IsolationSegment", ",", "Warnings", ",", "error", ")", "{", "isolationSegments", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetIsolationSegments", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "NameFilter", ",", "Values", ":", "[", "]", "string", "{", "name", "}", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IsolationSegment", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "isolationSegments", ")", "==", "0", "{", "return", "IsolationSegment", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "IsolationSegmentNotFoundError", "{", "Name", ":", "name", "}", "\n", "}", "\n\n", "return", "IsolationSegment", "(", "isolationSegments", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetIsolationSegmentByName returns the requested isolation segment.
[ "GetIsolationSegmentByName", "returns", "the", "requested", "isolation", "segment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L103-L116
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
GetIsolationSegmentSummaries
func (actor Actor) GetIsolationSegmentSummaries() ([]IsolationSegmentSummary, Warnings, error) { isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments() allWarnings := append(Warnings{}, warnings...) if err != nil { return nil, allWarnings, err } var isolationSegmentSummaries []IsolationSegmentSummary for _, isolationSegment := range isolationSegments { isolationSegmentSummary := IsolationSegmentSummary{ Name: isolationSegment.Name, EntitledOrgs: []string{}, } orgs, warnings, err := actor.CloudControllerClient.GetIsolationSegmentOrganizations(isolationSegment.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, org := range orgs { isolationSegmentSummary.EntitledOrgs = append(isolationSegmentSummary.EntitledOrgs, org.Name) } isolationSegmentSummaries = append(isolationSegmentSummaries, isolationSegmentSummary) } return isolationSegmentSummaries, allWarnings, nil }
go
func (actor Actor) GetIsolationSegmentSummaries() ([]IsolationSegmentSummary, Warnings, error) { isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments() allWarnings := append(Warnings{}, warnings...) if err != nil { return nil, allWarnings, err } var isolationSegmentSummaries []IsolationSegmentSummary for _, isolationSegment := range isolationSegments { isolationSegmentSummary := IsolationSegmentSummary{ Name: isolationSegment.Name, EntitledOrgs: []string{}, } orgs, warnings, err := actor.CloudControllerClient.GetIsolationSegmentOrganizations(isolationSegment.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, org := range orgs { isolationSegmentSummary.EntitledOrgs = append(isolationSegmentSummary.EntitledOrgs, org.Name) } isolationSegmentSummaries = append(isolationSegmentSummaries, isolationSegmentSummary) } return isolationSegmentSummaries, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetIsolationSegmentSummaries", "(", ")", "(", "[", "]", "IsolationSegmentSummary", ",", "Warnings", ",", "error", ")", "{", "isolationSegments", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetIsolationSegments", "(", ")", "\n", "allWarnings", ":=", "append", "(", "Warnings", "{", "}", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "var", "isolationSegmentSummaries", "[", "]", "IsolationSegmentSummary", "\n\n", "for", "_", ",", "isolationSegment", ":=", "range", "isolationSegments", "{", "isolationSegmentSummary", ":=", "IsolationSegmentSummary", "{", "Name", ":", "isolationSegment", ".", "Name", ",", "EntitledOrgs", ":", "[", "]", "string", "{", "}", ",", "}", "\n\n", "orgs", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetIsolationSegmentOrganizations", "(", "isolationSegment", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "org", ":=", "range", "orgs", "{", "isolationSegmentSummary", ".", "EntitledOrgs", "=", "append", "(", "isolationSegmentSummary", ".", "EntitledOrgs", ",", "org", ".", "Name", ")", "\n", "}", "\n\n", "isolationSegmentSummaries", "=", "append", "(", "isolationSegmentSummaries", ",", "isolationSegmentSummary", ")", "\n", "}", "\n", "return", "isolationSegmentSummaries", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetIsolationSegmentSummaries returns all isolation segments and their entitled orgs
[ "GetIsolationSegmentSummaries", "returns", "all", "isolation", "segments", "and", "their", "entitled", "orgs" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L119-L147
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
SetOrganizationDefaultIsolationSegment
func (actor Actor) SetOrganizationDefaultIsolationSegment(orgGUID string, isoSegGUID string) (Warnings, error) { _, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, isoSegGUID) return Warnings(apiWarnings), err }
go
func (actor Actor) SetOrganizationDefaultIsolationSegment(orgGUID string, isoSegGUID string) (Warnings, error) { _, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, isoSegGUID) return Warnings(apiWarnings), err }
[ "func", "(", "actor", "Actor", ")", "SetOrganizationDefaultIsolationSegment", "(", "orgGUID", "string", ",", "isoSegGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateOrganizationDefaultIsolationSegmentRelationship", "(", "orgGUID", ",", "isoSegGUID", ")", "\n", "return", "Warnings", "(", "apiWarnings", ")", ",", "err", "\n", "}" ]
// SetOrganizationDefaultIsolationSegment sets a default isolation segment on // an organization.
[ "SetOrganizationDefaultIsolationSegment", "sets", "a", "default", "isolation", "segment", "on", "an", "organization", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L188-L191
train
cloudfoundry/cli
actor/v3action/isolation_segment.go
ResetOrganizationDefaultIsolationSegment
func (actor Actor) ResetOrganizationDefaultIsolationSegment(orgGUID string) (Warnings, error) { _, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, "") return Warnings(apiWarnings), err }
go
func (actor Actor) ResetOrganizationDefaultIsolationSegment(orgGUID string) (Warnings, error) { _, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, "") return Warnings(apiWarnings), err }
[ "func", "(", "actor", "Actor", ")", "ResetOrganizationDefaultIsolationSegment", "(", "orgGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateOrganizationDefaultIsolationSegmentRelationship", "(", "orgGUID", ",", "\"", "\"", ")", "\n", "return", "Warnings", "(", "apiWarnings", ")", ",", "err", "\n", "}" ]
// ResetOrganizationDefaultIsolationSegment resets the default isolation segment fon // an organization.
[ "ResetOrganizationDefaultIsolationSegment", "resets", "the", "default", "isolation", "segment", "fon", "an", "organization", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L195-L198
train
cloudfoundry/cli
api/cloudcontroller/ccv3/package.go
UnmarshalJSON
func (p *Package) UnmarshalJSON(data []byte) error { var ccPackage struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Links APILinks `json:"links,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.PackageState `json:"state,omitempty"` Type constant.PackageType `json:"type,omitempty"` Data struct { Image string `json:"image"` Username string `json:"username"` Password string `json:"password"` } `json:"data"` } err := cloudcontroller.DecodeJSON(data, &ccPackage) if err != nil { return err } p.GUID = ccPackage.GUID p.CreatedAt = ccPackage.CreatedAt p.Links = ccPackage.Links p.Relationships = ccPackage.Relationships p.State = ccPackage.State p.Type = ccPackage.Type p.DockerImage = ccPackage.Data.Image p.DockerUsername = ccPackage.Data.Username p.DockerPassword = ccPackage.Data.Password return nil }
go
func (p *Package) UnmarshalJSON(data []byte) error { var ccPackage struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Links APILinks `json:"links,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.PackageState `json:"state,omitempty"` Type constant.PackageType `json:"type,omitempty"` Data struct { Image string `json:"image"` Username string `json:"username"` Password string `json:"password"` } `json:"data"` } err := cloudcontroller.DecodeJSON(data, &ccPackage) if err != nil { return err } p.GUID = ccPackage.GUID p.CreatedAt = ccPackage.CreatedAt p.Links = ccPackage.Links p.Relationships = ccPackage.Relationships p.State = ccPackage.State p.Type = ccPackage.Type p.DockerImage = ccPackage.Data.Image p.DockerUsername = ccPackage.Data.Username p.DockerPassword = ccPackage.Data.Password return nil }
[ "func", "(", "p", "*", "Package", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccPackage", "struct", "{", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "CreatedAt", "string", "`json:\"created_at,omitempty\"`", "\n", "Links", "APILinks", "`json:\"links,omitempty\"`", "\n", "Relationships", "Relationships", "`json:\"relationships,omitempty\"`", "\n", "State", "constant", ".", "PackageState", "`json:\"state,omitempty\"`", "\n", "Type", "constant", ".", "PackageType", "`json:\"type,omitempty\"`", "\n", "Data", "struct", "{", "Image", "string", "`json:\"image\"`", "\n", "Username", "string", "`json:\"username\"`", "\n", "Password", "string", "`json:\"password\"`", "\n", "}", "`json:\"data\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccPackage", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "p", ".", "GUID", "=", "ccPackage", ".", "GUID", "\n", "p", ".", "CreatedAt", "=", "ccPackage", ".", "CreatedAt", "\n", "p", ".", "Links", "=", "ccPackage", ".", "Links", "\n", "p", ".", "Relationships", "=", "ccPackage", ".", "Relationships", "\n", "p", ".", "State", "=", "ccPackage", ".", "State", "\n", "p", ".", "Type", "=", "ccPackage", ".", "Type", "\n", "p", ".", "DockerImage", "=", "ccPackage", ".", "Data", ".", "Image", "\n", "p", ".", "DockerUsername", "=", "ccPackage", ".", "Data", ".", "Username", "\n", "p", ".", "DockerPassword", "=", "ccPackage", ".", "Data", ".", "Password", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Package response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Package", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L84-L114
train
cloudfoundry/cli
api/cloudcontroller/ccv3/package.go
CreatePackage
func (client *Client) CreatePackage(pkg Package) (Package, Warnings, error) { bodyBytes, err := json.Marshal(pkg) if err != nil { return Package{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostPackageRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Package{}, nil, err } var responsePackage Package response := cloudcontroller.Response{ DecodeJSONResponseInto: &responsePackage, } err = client.connection.Make(request, &response) return responsePackage, response.Warnings, err }
go
func (client *Client) CreatePackage(pkg Package) (Package, Warnings, error) { bodyBytes, err := json.Marshal(pkg) if err != nil { return Package{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostPackageRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Package{}, nil, err } var responsePackage Package response := cloudcontroller.Response{ DecodeJSONResponseInto: &responsePackage, } err = client.connection.Make(request, &response) return responsePackage, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreatePackage", "(", "pkg", "Package", ")", "(", "Package", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "pkg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Package", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostPackageRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Package", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responsePackage", "Package", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responsePackage", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responsePackage", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreatePackage creates a package with the given settings, Type and the // ApplicationRelationship must be set.
[ "CreatePackage", "creates", "a", "package", "with", "the", "given", "settings", "Type", "and", "the", "ApplicationRelationship", "must", "be", "set", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L118-L139
train
cloudfoundry/cli
api/cloudcontroller/ccv3/package.go
GetPackage
func (client *Client) GetPackage(packageGUID string) (Package, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPackageRequest, URIParams: internal.Params{"package_guid": packageGUID}, }) if err != nil { return Package{}, nil, err } var responsePackage Package response := cloudcontroller.Response{ DecodeJSONResponseInto: &responsePackage, } err = client.connection.Make(request, &response) return responsePackage, response.Warnings, err }
go
func (client *Client) GetPackage(packageGUID string) (Package, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPackageRequest, URIParams: internal.Params{"package_guid": packageGUID}, }) if err != nil { return Package{}, nil, err } var responsePackage Package response := cloudcontroller.Response{ DecodeJSONResponseInto: &responsePackage, } err = client.connection.Make(request, &response) return responsePackage, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetPackage", "(", "packageGUID", "string", ")", "(", "Package", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetPackageRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "packageGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Package", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responsePackage", "Package", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responsePackage", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responsePackage", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetPackage returns the package with the given GUID.
[ "GetPackage", "returns", "the", "package", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L142-L158
train
cloudfoundry/cli
api/cloudcontroller/ccv3/package.go
GetPackages
func (client *Client) GetPackages(query ...Query) ([]Package, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPackagesRequest, Query: query, }) if err != nil { return nil, nil, err } var fullPackagesList []Package warnings, err := client.paginate(request, Package{}, func(item interface{}) error { if pkg, ok := item.(Package); ok { fullPackagesList = append(fullPackagesList, pkg) } else { return ccerror.UnknownObjectInListError{ Expected: Package{}, Unexpected: item, } } return nil }) return fullPackagesList, warnings, err }
go
func (client *Client) GetPackages(query ...Query) ([]Package, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPackagesRequest, Query: query, }) if err != nil { return nil, nil, err } var fullPackagesList []Package warnings, err := client.paginate(request, Package{}, func(item interface{}) error { if pkg, ok := item.(Package); ok { fullPackagesList = append(fullPackagesList, pkg) } else { return ccerror.UnknownObjectInListError{ Expected: Package{}, Unexpected: item, } } return nil }) return fullPackagesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetPackages", "(", "query", "...", "Query", ")", "(", "[", "]", "Package", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetPackagesRequest", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullPackagesList", "[", "]", "Package", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Package", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "pkg", ",", "ok", ":=", "item", ".", "(", "Package", ")", ";", "ok", "{", "fullPackagesList", "=", "append", "(", "fullPackagesList", ",", "pkg", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Package", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullPackagesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetPackages returns the list of packages.
[ "GetPackages", "returns", "the", "list", "of", "packages", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L161-L184
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_broker.go
UnmarshalJSON
func (serviceBroker *ServiceBroker) UnmarshalJSON(data []byte) error { var ccServiceBroker struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` BrokerURL string `json:"broker_url"` AuthUsername string `json:"auth_username"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccServiceBroker) if err != nil { return err } serviceBroker.Name = ccServiceBroker.Entity.Name serviceBroker.GUID = ccServiceBroker.Metadata.GUID serviceBroker.BrokerURL = ccServiceBroker.Entity.BrokerURL serviceBroker.AuthUsername = ccServiceBroker.Entity.AuthUsername serviceBroker.SpaceGUID = ccServiceBroker.Entity.SpaceGUID return nil }
go
func (serviceBroker *ServiceBroker) UnmarshalJSON(data []byte) error { var ccServiceBroker struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` BrokerURL string `json:"broker_url"` AuthUsername string `json:"auth_username"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccServiceBroker) if err != nil { return err } serviceBroker.Name = ccServiceBroker.Entity.Name serviceBroker.GUID = ccServiceBroker.Metadata.GUID serviceBroker.BrokerURL = ccServiceBroker.Entity.BrokerURL serviceBroker.AuthUsername = ccServiceBroker.Entity.AuthUsername serviceBroker.SpaceGUID = ccServiceBroker.Entity.SpaceGUID return nil }
[ "func", "(", "serviceBroker", "*", "ServiceBroker", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccServiceBroker", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "BrokerURL", "string", "`json:\"broker_url\"`", "\n", "AuthUsername", "string", "`json:\"auth_username\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccServiceBroker", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "serviceBroker", ".", "Name", "=", "ccServiceBroker", ".", "Entity", ".", "Name", "\n", "serviceBroker", ".", "GUID", "=", "ccServiceBroker", ".", "Metadata", ".", "GUID", "\n", "serviceBroker", ".", "BrokerURL", "=", "ccServiceBroker", ".", "Entity", ".", "BrokerURL", "\n", "serviceBroker", ".", "AuthUsername", "=", "ccServiceBroker", ".", "Entity", ".", "AuthUsername", "\n", "serviceBroker", ".", "SpaceGUID", "=", "ccServiceBroker", ".", "Entity", ".", "SpaceGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service Broker response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "Broker", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L27-L48
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_broker.go
CreateServiceBroker
func (client *Client) CreateServiceBroker(brokerName, username, password, url, spaceGUID string) (ServiceBroker, Warnings, error) { requestBody := createServiceBrokerRequestBody{ Name: brokerName, BrokerURL: url, AuthUsername: username, AuthPassword: password, SpaceGUID: spaceGUID, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceBroker{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceBrokerRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceBroker{}, nil, err } var serviceBroker ServiceBroker response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBroker, } err = client.connection.Make(request, &response) return serviceBroker, response.Warnings, err }
go
func (client *Client) CreateServiceBroker(brokerName, username, password, url, spaceGUID string) (ServiceBroker, Warnings, error) { requestBody := createServiceBrokerRequestBody{ Name: brokerName, BrokerURL: url, AuthUsername: username, AuthPassword: password, SpaceGUID: spaceGUID, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceBroker{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceBrokerRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceBroker{}, nil, err } var serviceBroker ServiceBroker response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBroker, } err = client.connection.Make(request, &response) return serviceBroker, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateServiceBroker", "(", "brokerName", ",", "username", ",", "password", ",", "url", ",", "spaceGUID", "string", ")", "(", "ServiceBroker", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "createServiceBrokerRequestBody", "{", "Name", ":", "brokerName", ",", "BrokerURL", ":", "url", ",", "AuthUsername", ":", "username", ",", "AuthPassword", ":", "password", ",", "SpaceGUID", ":", "spaceGUID", ",", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBroker", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceBrokerRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "ServiceBroker", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "serviceBroker", "ServiceBroker", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceBroker", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "serviceBroker", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateServiceBroker posts a service broker resource with the provided // attributes to the api and returns the result.
[ "CreateServiceBroker", "posts", "a", "service", "broker", "resource", "with", "the", "provided", "attributes", "to", "the", "api", "and", "returns", "the", "result", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L60-L91
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_broker.go
GetServiceBrokers
func (client *Client) GetServiceBrokers(filters ...Filter) ([]ServiceBroker, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBrokersRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullBrokersList []ServiceBroker warnings, err := client.paginate(request, ServiceBroker{}, func(item interface{}) error { if broker, ok := item.(ServiceBroker); ok { fullBrokersList = append(fullBrokersList, broker) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBroker{}, Unexpected: item, } } return nil }) return fullBrokersList, warnings, err }
go
func (client *Client) GetServiceBrokers(filters ...Filter) ([]ServiceBroker, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBrokersRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullBrokersList []ServiceBroker warnings, err := client.paginate(request, ServiceBroker{}, func(item interface{}) error { if broker, ok := item.(ServiceBroker); ok { fullBrokersList = append(fullBrokersList, broker) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBroker{}, Unexpected: item, } } return nil }) return fullBrokersList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceBrokers", "(", "filters", "...", "Filter", ")", "(", "[", "]", "ServiceBroker", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceBrokersRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullBrokersList", "[", "]", "ServiceBroker", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceBroker", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "broker", ",", "ok", ":=", "item", ".", "(", "ServiceBroker", ")", ";", "ok", "{", "fullBrokersList", "=", "append", "(", "fullBrokersList", ",", "broker", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceBroker", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullBrokersList", ",", "warnings", ",", "err", "\n", "}" ]
// GetServiceBrokers returns back a list of Service Brokers given the provided // filters.
[ "GetServiceBrokers", "returns", "back", "a", "list", "of", "Service", "Brokers", "given", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L95-L119
train
cloudfoundry/cli
cf/util/glob/glob.go
MustCompileGlob
func MustCompileGlob(pat string) Glob { g, err := CompileGlob(pat) if err != nil { panic(err) } return g }
go
func MustCompileGlob(pat string) Glob { g, err := CompileGlob(pat) if err != nil { panic(err) } return g }
[ "func", "MustCompileGlob", "(", "pat", "string", ")", "Glob", "{", "g", ",", "err", ":=", "CompileGlob", "(", "pat", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "g", "\n", "}" ]
// MustCompileGlob is like CompileGlob, but it panics if an error occurs, // simplifying safe initialization of global variables holding glob patterns.
[ "MustCompileGlob", "is", "like", "CompileGlob", "but", "it", "panics", "if", "an", "error", "occurs", "simplifying", "safe", "initialization", "of", "global", "variables", "holding", "glob", "patterns", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/glob/glob.go#L84-L90
train
cloudfoundry/cli
actor/v7action/buildpack.go
GetBuildpackByNameAndStack
func (actor Actor) GetBuildpackByNameAndStack(buildpackName string, buildpackStack string) (Buildpack, Warnings, error) { var ( ccv3Buildpacks []ccv3.Buildpack warnings ccv3.Warnings err error ) if buildpackStack == "" { ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(ccv3.Query{ Key: ccv3.NameFilter, Values: []string{buildpackName}, }) } else { ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks( ccv3.Query{ Key: ccv3.NameFilter, Values: []string{buildpackName}, }, ccv3.Query{ Key: ccv3.StackFilter, Values: []string{buildpackStack}, }, ) } if err != nil { return Buildpack{}, Warnings(warnings), err } if len(ccv3Buildpacks) == 0 { return Buildpack{}, Warnings(warnings), actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack} } if len(ccv3Buildpacks) > 1 { for _, buildpack := range ccv3Buildpacks { if buildpack.Stack == "" { return Buildpack(buildpack), Warnings(warnings), nil } } return Buildpack{}, Warnings(warnings), actionerror.MultipleBuildpacksFoundError{BuildpackName: buildpackName} } return Buildpack(ccv3Buildpacks[0]), Warnings(warnings), err }
go
func (actor Actor) GetBuildpackByNameAndStack(buildpackName string, buildpackStack string) (Buildpack, Warnings, error) { var ( ccv3Buildpacks []ccv3.Buildpack warnings ccv3.Warnings err error ) if buildpackStack == "" { ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(ccv3.Query{ Key: ccv3.NameFilter, Values: []string{buildpackName}, }) } else { ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks( ccv3.Query{ Key: ccv3.NameFilter, Values: []string{buildpackName}, }, ccv3.Query{ Key: ccv3.StackFilter, Values: []string{buildpackStack}, }, ) } if err != nil { return Buildpack{}, Warnings(warnings), err } if len(ccv3Buildpacks) == 0 { return Buildpack{}, Warnings(warnings), actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack} } if len(ccv3Buildpacks) > 1 { for _, buildpack := range ccv3Buildpacks { if buildpack.Stack == "" { return Buildpack(buildpack), Warnings(warnings), nil } } return Buildpack{}, Warnings(warnings), actionerror.MultipleBuildpacksFoundError{BuildpackName: buildpackName} } return Buildpack(ccv3Buildpacks[0]), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetBuildpackByNameAndStack", "(", "buildpackName", "string", ",", "buildpackStack", "string", ")", "(", "Buildpack", ",", "Warnings", ",", "error", ")", "{", "var", "(", "ccv3Buildpacks", "[", "]", "ccv3", ".", "Buildpack", "\n", "warnings", "ccv3", ".", "Warnings", "\n", "err", "error", "\n", ")", "\n\n", "if", "buildpackStack", "==", "\"", "\"", "{", "ccv3Buildpacks", ",", "warnings", ",", "err", "=", "actor", ".", "CloudControllerClient", ".", "GetBuildpacks", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "NameFilter", ",", "Values", ":", "[", "]", "string", "{", "buildpackName", "}", ",", "}", ")", "\n", "}", "else", "{", "ccv3Buildpacks", ",", "warnings", ",", "err", "=", "actor", ".", "CloudControllerClient", ".", "GetBuildpacks", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "NameFilter", ",", "Values", ":", "[", "]", "string", "{", "buildpackName", "}", ",", "}", ",", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "StackFilter", ",", "Values", ":", "[", "]", "string", "{", "buildpackStack", "}", ",", "}", ",", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "return", "Buildpack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "ccv3Buildpacks", ")", "==", "0", "{", "return", "Buildpack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "BuildpackNotFoundError", "{", "BuildpackName", ":", "buildpackName", ",", "StackName", ":", "buildpackStack", "}", "\n", "}", "\n\n", "if", "len", "(", "ccv3Buildpacks", ")", ">", "1", "{", "for", "_", ",", "buildpack", ":=", "range", "ccv3Buildpacks", "{", "if", "buildpack", ".", "Stack", "==", "\"", "\"", "{", "return", "Buildpack", "(", "buildpack", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "Buildpack", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "MultipleBuildpacksFoundError", "{", "BuildpackName", ":", "buildpackName", "}", "\n", "}", "\n\n", "return", "Buildpack", "(", "ccv3Buildpacks", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetBuildpackByNameAndStack returns a buildpack with the provided name and // stack. If `buildpackStack` is not specified, and there are multiple // buildpacks with the same name, it will return the one with no stack, if // present.
[ "GetBuildpackByNameAndStack", "returns", "a", "buildpack", "with", "the", "provided", "name", "and", "stack", ".", "If", "buildpackStack", "is", "not", "specified", "and", "there", "are", "multiple", "buildpacks", "with", "the", "same", "name", "it", "will", "return", "the", "one", "with", "no", "stack", "if", "present", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/buildpack.go#L42-L85
train
cloudfoundry/cli
actor/v3action/droplet.go
SetApplicationDropletByApplicationNameAndSpace
func (actor Actor) SetApplicationDropletByApplicationNameAndSpace(appName string, spaceGUID string, dropletGUID string) (Warnings, error) { allWarnings := Warnings{} application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } _, apiWarnings, err := actor.CloudControllerClient.SetApplicationDroplet(application.GUID, dropletGUID) actorWarnings := Warnings(apiWarnings) allWarnings = append(allWarnings, actorWarnings...) if newErr, ok := err.(ccerror.UnprocessableEntityError); ok { return allWarnings, actionerror.AssignDropletError{Message: newErr.Message} } return allWarnings, err }
go
func (actor Actor) SetApplicationDropletByApplicationNameAndSpace(appName string, spaceGUID string, dropletGUID string) (Warnings, error) { allWarnings := Warnings{} application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } _, apiWarnings, err := actor.CloudControllerClient.SetApplicationDroplet(application.GUID, dropletGUID) actorWarnings := Warnings(apiWarnings) allWarnings = append(allWarnings, actorWarnings...) if newErr, ok := err.(ccerror.UnprocessableEntityError); ok { return allWarnings, actionerror.AssignDropletError{Message: newErr.Message} } return allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "SetApplicationDropletByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "dropletGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "allWarnings", ":=", "Warnings", "{", "}", "\n", "application", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n", "_", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "SetApplicationDroplet", "(", "application", ".", "GUID", ",", "dropletGUID", ")", "\n", "actorWarnings", ":=", "Warnings", "(", "apiWarnings", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "actorWarnings", "...", ")", "\n\n", "if", "newErr", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "UnprocessableEntityError", ")", ";", "ok", "{", "return", "allWarnings", ",", "actionerror", ".", "AssignDropletError", "{", "Message", ":", "newErr", ".", "Message", "}", "\n", "}", "\n\n", "return", "allWarnings", ",", "err", "\n", "}" ]
// SetApplicationDropletByApplicationNameAndSpace sets the droplet for an application.
[ "SetApplicationDropletByApplicationNameAndSpace", "sets", "the", "droplet", "for", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/droplet.go#L23-L39
train
cloudfoundry/cli
actor/v3action/droplet.go
GetApplicationDroplets
func (actor Actor) GetApplicationDroplets(appName string, spaceGUID string) ([]Droplet, Warnings, error) { allWarnings := Warnings{} application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } ccv3Droplets, apiWarnings, err := actor.CloudControllerClient.GetDroplets( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{application.GUID}}, ) actorWarnings := Warnings(apiWarnings) allWarnings = append(allWarnings, actorWarnings...) if err != nil { return nil, allWarnings, err } var droplets []Droplet for _, ccv3Droplet := range ccv3Droplets { droplets = append(droplets, actor.convertCCToActorDroplet(ccv3Droplet)) } return droplets, allWarnings, err }
go
func (actor Actor) GetApplicationDroplets(appName string, spaceGUID string) ([]Droplet, Warnings, error) { allWarnings := Warnings{} application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } ccv3Droplets, apiWarnings, err := actor.CloudControllerClient.GetDroplets( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{application.GUID}}, ) actorWarnings := Warnings(apiWarnings) allWarnings = append(allWarnings, actorWarnings...) if err != nil { return nil, allWarnings, err } var droplets []Droplet for _, ccv3Droplet := range ccv3Droplets { droplets = append(droplets, actor.convertCCToActorDroplet(ccv3Droplet)) } return droplets, allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "GetApplicationDroplets", "(", "appName", "string", ",", "spaceGUID", "string", ")", "(", "[", "]", "Droplet", ",", "Warnings", ",", "error", ")", "{", "allWarnings", ":=", "Warnings", "{", "}", "\n", "application", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "ccv3Droplets", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetDroplets", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "AppGUIDFilter", ",", "Values", ":", "[", "]", "string", "{", "application", ".", "GUID", "}", "}", ",", ")", "\n", "actorWarnings", ":=", "Warnings", "(", "apiWarnings", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "actorWarnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "var", "droplets", "[", "]", "Droplet", "\n", "for", "_", ",", "ccv3Droplet", ":=", "range", "ccv3Droplets", "{", "droplets", "=", "append", "(", "droplets", ",", "actor", ".", "convertCCToActorDroplet", "(", "ccv3Droplet", ")", ")", "\n", "}", "\n\n", "return", "droplets", ",", "allWarnings", ",", "err", "\n", "}" ]
// GetApplicationDroplets returns the list of droplets that belong to applicaiton.
[ "GetApplicationDroplets", "returns", "the", "list", "of", "droplets", "that", "belong", "to", "applicaiton", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/droplet.go#L52-L75
train
cloudfoundry/cli
api/cloudcontroller/ccv2/resource.go
UpdateResourceMatch
func (client *Client) UpdateResourceMatch(resourcesToMatch []Resource) ([]Resource, Warnings, error) { body, err := json.Marshal(resourcesToMatch) if err != nil { return nil, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutResourceMatchRequest, Body: bytes.NewReader(body), }) if err != nil { return nil, nil, err } request.Header.Set("Content-Type", "application/json") var matchedResources []Resource response := cloudcontroller.Response{ DecodeJSONResponseInto: &matchedResources, } err = client.connection.Make(request, &response) return matchedResources, response.Warnings, err }
go
func (client *Client) UpdateResourceMatch(resourcesToMatch []Resource) ([]Resource, Warnings, error) { body, err := json.Marshal(resourcesToMatch) if err != nil { return nil, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutResourceMatchRequest, Body: bytes.NewReader(body), }) if err != nil { return nil, nil, err } request.Header.Set("Content-Type", "application/json") var matchedResources []Resource response := cloudcontroller.Response{ DecodeJSONResponseInto: &matchedResources, } err = client.connection.Make(request, &response) return matchedResources, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateResourceMatch", "(", "resourcesToMatch", "[", "]", "Resource", ")", "(", "[", "]", "Resource", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "resourcesToMatch", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutResourceMatchRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "var", "matchedResources", "[", "]", "Resource", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "matchedResources", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "matchedResources", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateResourceMatch returns the resources that exist on the cloud foundry instance // from the set of resources given.
[ "UpdateResourceMatch", "returns", "the", "resources", "that", "exist", "on", "the", "cloud", "foundry", "instance", "from", "the", "set", "of", "resources", "given", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/resource.go#L74-L97
train
cloudfoundry/cli
api/uaa/user.go
CreateUser
func (client *Client) CreateUser(user string, password string, origin string) (User, error) { userRequest := newUserRequestBody{ Username: user, Password: password, Origin: origin, Name: userName{ FamilyName: user, GivenName: user, }, Emails: []email{ { Value: user, Primary: true, }, }, } bodyBytes, err := json.Marshal(userRequest) if err != nil { return User{}, err } request, err := client.newRequest(requestOptions{ RequestName: internal.PostUserRequest, Header: http.Header{ "Content-Type": {"application/json"}, }, Body: bytes.NewBuffer(bodyBytes), }) if err != nil { return User{}, err } var userResponse newUserResponse response := Response{ Result: &userResponse, } err = client.connection.Make(request, &response) if err != nil { return User{}, err } return User(userResponse), nil }
go
func (client *Client) CreateUser(user string, password string, origin string) (User, error) { userRequest := newUserRequestBody{ Username: user, Password: password, Origin: origin, Name: userName{ FamilyName: user, GivenName: user, }, Emails: []email{ { Value: user, Primary: true, }, }, } bodyBytes, err := json.Marshal(userRequest) if err != nil { return User{}, err } request, err := client.newRequest(requestOptions{ RequestName: internal.PostUserRequest, Header: http.Header{ "Content-Type": {"application/json"}, }, Body: bytes.NewBuffer(bodyBytes), }) if err != nil { return User{}, err } var userResponse newUserResponse response := Response{ Result: &userResponse, } err = client.connection.Make(request, &response) if err != nil { return User{}, err } return User(userResponse), nil }
[ "func", "(", "client", "*", "Client", ")", "CreateUser", "(", "user", "string", ",", "password", "string", ",", "origin", "string", ")", "(", "User", ",", "error", ")", "{", "userRequest", ":=", "newUserRequestBody", "{", "Username", ":", "user", ",", "Password", ":", "password", ",", "Origin", ":", "origin", ",", "Name", ":", "userName", "{", "FamilyName", ":", "user", ",", "GivenName", ":", "user", ",", "}", ",", "Emails", ":", "[", "]", "email", "{", "{", "Value", ":", "user", ",", "Primary", ":", "true", ",", "}", ",", "}", ",", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "userRequest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostUserRequest", ",", "Header", ":", "http", ".", "Header", "{", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "}", ",", "Body", ":", "bytes", ".", "NewBuffer", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "userResponse", "newUserResponse", "\n", "response", ":=", "Response", "{", "Result", ":", "&", "userResponse", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "User", "(", "userResponse", ")", ",", "nil", "\n", "}" ]
// CreateUser creates a new UAA user account with the provided password.
[ "CreateUser", "creates", "a", "new", "UAA", "user", "account", "with", "the", "provided", "password", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/user.go#L41-L85
train
cloudfoundry/cli
actor/v2action/resource.go
ResourceMatch
func (actor Actor) ResourceMatch(allResources []Resource) ([]Resource, []Resource, Warnings, error) { resourcesToSend := [][]ccv2.Resource{{}} var currentList, sendCount int for _, resource := range allResources { // Skip if resource is a directory, symlink, or empty file. if resource.Size == 0 { continue } resourcesToSend[currentList] = append( resourcesToSend[currentList], ccv2.Resource(resource), ) sendCount++ if len(resourcesToSend[currentList]) == MaxResourceMatchChunkSize { currentList++ resourcesToSend = append(resourcesToSend, []ccv2.Resource{}) } } log.WithFields(log.Fields{ "total_resources": len(allResources), "resources_to_match": sendCount, "chunks": len(resourcesToSend), }).Debug("sending resource match stats") matchedCCResources := map[string]ccv2.Resource{} var allWarnings Warnings for _, chunk := range resourcesToSend { if len(chunk) == 0 { log.Debug("chunk size 0, stopping resource match requests") break } returnedResources, warnings, err := actor.CloudControllerClient.UpdateResourceMatch(chunk) allWarnings = append(allWarnings, warnings...) if err != nil { log.Errorln("during resource matching", err) return nil, nil, allWarnings, err } for _, resource := range returnedResources { matchedCCResources[resource.SHA1] = resource } } log.WithField("matched_resource_count", len(matchedCCResources)).Debug("total number of matched resources") var matchedResources, unmatchedResources []Resource for _, resource := range allResources { if _, ok := matchedCCResources[resource.SHA1]; ok { matchedResources = append(matchedResources, resource) } else { unmatchedResources = append(unmatchedResources, resource) } } return matchedResources, unmatchedResources, allWarnings, nil }
go
func (actor Actor) ResourceMatch(allResources []Resource) ([]Resource, []Resource, Warnings, error) { resourcesToSend := [][]ccv2.Resource{{}} var currentList, sendCount int for _, resource := range allResources { // Skip if resource is a directory, symlink, or empty file. if resource.Size == 0 { continue } resourcesToSend[currentList] = append( resourcesToSend[currentList], ccv2.Resource(resource), ) sendCount++ if len(resourcesToSend[currentList]) == MaxResourceMatchChunkSize { currentList++ resourcesToSend = append(resourcesToSend, []ccv2.Resource{}) } } log.WithFields(log.Fields{ "total_resources": len(allResources), "resources_to_match": sendCount, "chunks": len(resourcesToSend), }).Debug("sending resource match stats") matchedCCResources := map[string]ccv2.Resource{} var allWarnings Warnings for _, chunk := range resourcesToSend { if len(chunk) == 0 { log.Debug("chunk size 0, stopping resource match requests") break } returnedResources, warnings, err := actor.CloudControllerClient.UpdateResourceMatch(chunk) allWarnings = append(allWarnings, warnings...) if err != nil { log.Errorln("during resource matching", err) return nil, nil, allWarnings, err } for _, resource := range returnedResources { matchedCCResources[resource.SHA1] = resource } } log.WithField("matched_resource_count", len(matchedCCResources)).Debug("total number of matched resources") var matchedResources, unmatchedResources []Resource for _, resource := range allResources { if _, ok := matchedCCResources[resource.SHA1]; ok { matchedResources = append(matchedResources, resource) } else { unmatchedResources = append(unmatchedResources, resource) } } return matchedResources, unmatchedResources, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "ResourceMatch", "(", "allResources", "[", "]", "Resource", ")", "(", "[", "]", "Resource", ",", "[", "]", "Resource", ",", "Warnings", ",", "error", ")", "{", "resourcesToSend", ":=", "[", "]", "[", "]", "ccv2", ".", "Resource", "{", "{", "}", "}", "\n", "var", "currentList", ",", "sendCount", "int", "\n", "for", "_", ",", "resource", ":=", "range", "allResources", "{", "// Skip if resource is a directory, symlink, or empty file.", "if", "resource", ".", "Size", "==", "0", "{", "continue", "\n", "}", "\n\n", "resourcesToSend", "[", "currentList", "]", "=", "append", "(", "resourcesToSend", "[", "currentList", "]", ",", "ccv2", ".", "Resource", "(", "resource", ")", ",", ")", "\n", "sendCount", "++", "\n\n", "if", "len", "(", "resourcesToSend", "[", "currentList", "]", ")", "==", "MaxResourceMatchChunkSize", "{", "currentList", "++", "\n", "resourcesToSend", "=", "append", "(", "resourcesToSend", ",", "[", "]", "ccv2", ".", "Resource", "{", "}", ")", "\n", "}", "\n", "}", "\n\n", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "len", "(", "allResources", ")", ",", "\"", "\"", ":", "sendCount", ",", "\"", "\"", ":", "len", "(", "resourcesToSend", ")", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "matchedCCResources", ":=", "map", "[", "string", "]", "ccv2", ".", "Resource", "{", "}", "\n", "var", "allWarnings", "Warnings", "\n", "for", "_", ",", "chunk", ":=", "range", "resourcesToSend", "{", "if", "len", "(", "chunk", ")", "==", "0", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "break", "\n", "}", "\n\n", "returnedResources", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateResourceMatch", "(", "chunk", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "resource", ":=", "range", "returnedResources", "{", "matchedCCResources", "[", "resource", ".", "SHA1", "]", "=", "resource", "\n", "}", "\n", "}", "\n", "log", ".", "WithField", "(", "\"", "\"", ",", "len", "(", "matchedCCResources", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "var", "matchedResources", ",", "unmatchedResources", "[", "]", "Resource", "\n", "for", "_", ",", "resource", ":=", "range", "allResources", "{", "if", "_", ",", "ok", ":=", "matchedCCResources", "[", "resource", ".", "SHA1", "]", ";", "ok", "{", "matchedResources", "=", "append", "(", "matchedResources", ",", "resource", ")", "\n", "}", "else", "{", "unmatchedResources", "=", "append", "(", "unmatchedResources", ",", "resource", ")", "\n", "}", "\n", "}", "\n\n", "return", "matchedResources", ",", "unmatchedResources", ",", "allWarnings", ",", "nil", "\n", "}" ]
// ResourceMatch returns a set of matched resources and unmatched resources in // the order they were given in allResources.
[ "ResourceMatch", "returns", "a", "set", "of", "matched", "resources", "and", "unmatched", "resources", "in", "the", "order", "they", "were", "given", "in", "allResources", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/resource.go#L30-L89
train