Skip to content

Commit 2f98227

Browse files
authored
Update project.go
1 parent ab410f1 commit 2f98227

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

pkg/dbt_cloud/project.go

+4-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type ProjectResponse struct {
3030
}
3131

3232
func (c *Client) GetProject(projectID string) (*Project, error) {
33-
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v3/accounts/%s/projects/", c.HostURL, strconv.Itoa(c.AccountID)), nil)
33+
req, err := http.NewRequest("GET", fmt.Sprintf("%s/v3/accounts/%s/projects/%s/", c.HostURL, strconv.Itoa(c.AccountID), projectID), nil)
3434
if err != nil {
3535
return nil, err
3636
}
@@ -40,19 +40,13 @@ func (c *Client) GetProject(projectID string) (*Project, error) {
4040
return nil, err
4141
}
4242

43-
projectListResponse := ProjectListResponse{}
44-
err = json.Unmarshal(body, &projectListResponse)
43+
projectResponse := ProjectResponse{}
44+
err = json.Unmarshal(body, &projectResponse)
4545
if err != nil {
4646
return nil, err
4747
}
4848

49-
for i, project := range projectListResponse.Data {
50-
if strconv.Itoa(*project.ID) == projectID {
51-
return &projectListResponse.Data[i], nil
52-
}
53-
}
54-
55-
return nil, fmt.Errorf("Did not find project ID %d in account ID %d", projectID, strconv.Itoa(c.AccountID))
49+
return &projectResponse.Data, nil
5650
}
5751

5852
func (c *Client) CreateProject(name string, dbtProjectSubdirectory string, connectionID int, repositoryID int) (*Project, error) {

0 commit comments

Comments
 (0)