diff --git a/environments.go b/environments.go index cee6aaf63..b6d902f86 100644 --- a/environments.go +++ b/environments.go @@ -204,18 +204,26 @@ func (s *EnvironmentsService) DeleteEnvironment(pid interface{}, environment int return s.client.Do(req, nil) } -// StopEnvironment stop an environment from a project team. +// StopEnvironmentOptions represents the available StopEnvironment() options. // // GitLab API docs: // https://docs.gitlab.com/ee/api/environments.html#stop-an-environment -func (s *EnvironmentsService) StopEnvironment(pid interface{}, environmentID int, options ...RequestOptionFunc) (*Environment, *Response, error) { +type StopEnvironmentOptions struct { + Force *bool `url:"force,omitempty" json:"force,omitempty"` +} + +// StopEnvironment stops an environment within a specific project. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/environments.html#stop-an-environment +func (s *EnvironmentsService) StopEnvironment(pid interface{}, environmentID int, opt *StopEnvironmentOptions, options ...RequestOptionFunc) (*Environment, *Response, error) { project, err := parseID(pid) if err != nil { return nil, nil, err } u := fmt.Sprintf("projects/%s/environments/%d/stop", PathEscape(project), environmentID) - req, err := s.client.NewRequest(http.MethodPost, u, nil, options) + req, err := s.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } diff --git a/environments_test.go b/environments_test.go index bdfb4bf2e..717ac8f4f 100644 --- a/environments_test.go +++ b/environments_test.go @@ -185,7 +185,7 @@ func TestStopEnvironment(t *testing.T) { "tier": "staging" }`) }) - _, _, err := client.Environments.StopEnvironment(1, 1) + _, _, err := client.Environments.StopEnvironment(1, 1, &StopEnvironmentOptions{}) if err != nil { log.Fatal(err) }