MCPcopy Create free account
hub / github.com/cli/cli / StopCodespace

Method StopCodespace

internal/codespaces/api/api.go:619–652  ·  view source on GitHub ↗
(ctx context.Context, codespaceName string, orgName string, userName string)

Source from the content-addressed store, hash-verified

617}
618
619func (a *API) StopCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error {
620 var stopURL *safeurl.MutableSafeURL
621 var spanName string
622 var err error
623
624 if orgName != "" {
625 stopURL, err = safeurl.JoinPathWithHostPrefix(a.githubAPI, "orgs", orgName, "members", userName, "codespaces", codespaceName, "stop")
626 spanName = "/orgs/*/members/*/codespaces/*/stop"
627 } else {
628 stopURL, err = safeurl.JoinPathWithHostPrefix(a.githubAPI, "user", "codespaces", codespaceName, "stop")
629 spanName = "/user/codespaces/*/stop"
630 }
631 if err != nil {
632 return err
633 }
634
635 req, err := http.NewRequest(http.MethodPost, stopURL.String(), nil)
636 if err != nil {
637 return fmt.Errorf("error creating request: %w", err)
638 }
639
640 a.setHeaders(req)
641 resp, err := a.do(ctx, req, spanName)
642 if err != nil {
643 return fmt.Errorf("error making request: %w", err)
644 }
645 defer resp.Body.Close()
646
647 if resp.StatusCode != http.StatusOK {
648 return api.HandleHTTPError(resp)
649 }
650
651 return nil
652}
653
654type Machine struct {
655 Name string `json:"name"`

Callers

nothing calls this directly

Calls 7

StringMethod · 0.95
setHeadersMethod · 0.95
doMethod · 0.95
JoinPathWithHostPrefixFunction · 0.92
HandleHTTPErrorFunction · 0.92
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected