Skip to content

Commit

Permalink
Add TODO for future cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per committed Aug 16, 2024
1 parent 1b36b20 commit 46084fd
Showing 1 changed file with 49 additions and 6 deletions.
55 changes: 49 additions & 6 deletions pkg/dbt_cloud/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Environment struct {
Type string `json:"type"`
Use_Custom_Branch bool `json:"use_custom_branch"`
Custom_Branch *string `json:"custom_branch"`
Environment_Id *int `json:"-"`
Environment_Id *int `json:"-"` //TODO: check why this is here
Support_Docs bool `json:"supports_docs"`
Created_At *string `json:"created_at"`
Updated_At *string `json:"updated_at"`
Expand All @@ -37,7 +37,17 @@ type Environment struct {
}

func (c *Client) GetEnvironment(projectId int, environmentId int) (*Environment, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v3/accounts/%d/projects/%d/environments/%d/", c.HostURL, c.AccountID, projectId, environmentId), nil)
req, err := http.NewRequest(
"GET",
fmt.Sprintf(
"%s/v3/accounts/%d/projects/%d/environments/%d/",
c.HostURL,
c.AccountID,
projectId,
environmentId,
),
nil,
)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -104,7 +114,16 @@ func (c *Client) CreateEnvironment(
return nil, err
}

req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/accounts/%d/projects/%d/environments/", c.HostURL, c.AccountID, projectId), strings.NewReader(string(newEnvironmentData)))
req, err := http.NewRequest(
"POST",
fmt.Sprintf(
"%s/v3/accounts/%d/projects/%d/environments/",
c.HostURL,
c.AccountID,
projectId,
),
strings.NewReader(string(newEnvironmentData)),
)
if err != nil {
return nil, err
}
Expand All @@ -124,7 +143,11 @@ func (c *Client) CreateEnvironment(
return &environmentResponse.Data, nil
}

func (c *Client) UpdateEnvironment(projectId int, environmentId int, environment Environment) (*Environment, error) {
func (c *Client) UpdateEnvironment(
projectId int,
environmentId int,
environment Environment,
) (*Environment, error) {

// we don't send the environment details in the update request, just the credential_id
environment.Credentials = nil
Expand All @@ -134,7 +157,17 @@ func (c *Client) UpdateEnvironment(projectId int, environmentId int, environment
return nil, err
}

req, err := http.NewRequest("POST", fmt.Sprintf("%s/v3/accounts/%d/projects/%d/environments/%d/", c.HostURL, c.AccountID, projectId, environmentId), strings.NewReader(string(environmentData)))
req, err := http.NewRequest(
"POST",
fmt.Sprintf(
"%s/v3/accounts/%d/projects/%d/environments/%d/",
c.HostURL,
c.AccountID,
projectId,
environmentId,
),
strings.NewReader(string(environmentData)),
)
if err != nil {
return nil, err
}
Expand All @@ -155,7 +188,17 @@ func (c *Client) UpdateEnvironment(projectId int, environmentId int, environment
}

func (c *Client) DeleteEnvironment(projectId, environmentId int) (string, error) {
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/v3/accounts/%d/projects/%d/environments/%d/", c.HostURL, c.AccountID, projectId, environmentId), nil)
req, err := http.NewRequest(
"DELETE",
fmt.Sprintf(
"%s/v3/accounts/%d/projects/%d/environments/%d/",
c.HostURL,
c.AccountID,
projectId,
environmentId,
),
nil,
)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 46084fd

Please sign in to comment.