MCPcopy Index your code
hub / github.com/cli/cli / StopCodespace

Method StopCodespace

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

Source from the content-addressed store, hash-verified

567}
568
569func (a *API) StopCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error {
570 var stopURL string
571 var spanName string
572
573 if orgName != "" {
574 stopURL = fmt.Sprintf("%s/orgs/%s/members/%s/codespaces/%s/stop", a.githubAPI, orgName, userName, codespaceName)
575 spanName = "/orgs/*/members/*/codespaces/*/stop"
576 } else {
577 stopURL = fmt.Sprintf("%s/user/codespaces/%s/stop", a.githubAPI, codespaceName)
578 spanName = "/user/codespaces/*/stop"
579 }
580
581 req, err := http.NewRequest(http.MethodPost, stopURL, nil)
582 if err != nil {
583 return fmt.Errorf("error creating request: %w", err)
584 }
585
586 a.setHeaders(req)
587 resp, err := a.do(ctx, req, spanName)
588 if err != nil {
589 return fmt.Errorf("error making request: %w", err)
590 }
591 defer resp.Body.Close()
592
593 if resp.StatusCode != http.StatusOK {
594 return api.HandleHTTPError(resp)
595 }
596
597 return nil
598}
599
600type Machine struct {
601 Name string `json:"name"`

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected