@@ -7,32 +7,34 @@ import (
7
7
"strings"
8
8
)
9
9
10
- type EnvironmentListResponse struct {
11
- Data []Environment `json:"data"`
12
- Status ResponseStatus `json:"status"`
13
- }
14
-
15
10
type EnvironmentResponse struct {
16
11
Data Environment `json:"data"`
17
12
Status ResponseStatus `json:"status"`
18
13
}
19
14
20
15
type Environment struct {
21
- ID * int `json:"id,omitempty"`
22
- State int `json:"state,omitempty"`
23
- Account_Id int `json:"account_id"`
24
- Project_Id int `json:"project_id"`
25
- Credential_Id * int `json:"credentials_id,omitempty"`
26
- Name string `json:"name"`
27
- Dbt_Version string `json:"dbt_version"`
28
- Type string `json:"type"`
29
- Use_Custom_Branch bool `json:"use_custom_branch"`
30
- Custom_Branch * string `json:"custom_branch,omitempty"`
31
- Environment_Id * int `json:"environment_id,omitempty"`
16
+ ID * int `json:"id,omitempty"`
17
+ State int `json:"state,omitempty"`
18
+ Account_Id int `json:"account_id"`
19
+ Project_Id int `json:"project_id"`
20
+ Credential_Id * int `json:"credentials_id"`
21
+ Name string `json:"name"`
22
+ Dbt_Version string `json:"dbt_version"`
23
+ Type string `json:"type"`
24
+ Use_Custom_Branch bool `json:"use_custom_branch"`
25
+ Custom_Branch * string `json:"custom_branch"`
26
+ Environment_Id * int `json:"-"`
27
+ Support_Docs bool `json:"supports_docs"`
28
+ Created_At * string `json:"created_at"`
29
+ Updated_At * string `json:"updated_at"`
30
+ Project Project `json:"project"`
31
+ Jobs * string `json:"jobs"`
32
+ Credentials * string `json:"credentials"`
33
+ Custom_Environment_Variables * string `json:"custom_environment_variables"`
32
34
}
33
35
34
36
func (c * Client ) GetEnvironment (projectId int , environmentId int ) (* Environment , error ) {
35
- req , err := http .NewRequest ("GET" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/" , HostURL , c .AccountID , projectId ), nil )
37
+ req , err := http .NewRequest ("GET" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/%d/ " , HostURL , c .AccountID , projectId , environmentId ), nil )
36
38
if err != nil {
37
39
return nil , err
38
40
}
@@ -42,20 +44,14 @@ func (c *Client) GetEnvironment(projectId int, environmentId int) (*Environment,
42
44
return nil , err
43
45
}
44
46
45
- environmentListResponse := EnvironmentListResponse {}
46
- err = json .Unmarshal (body , & environmentListResponse )
47
+ environmentResponse := EnvironmentResponse {}
48
+ err = json .Unmarshal (body , & environmentResponse )
47
49
if err != nil {
48
50
return nil , err
49
51
}
50
52
51
- for i , environment := range environmentListResponse .Data {
52
- if * environment .ID == environmentId {
53
- environmentListResponse .Data [i ].Environment_Id = & environmentId
54
- return & environmentListResponse .Data [i ], nil
55
- }
56
- }
57
-
58
- return nil , fmt .Errorf ("did not find environment ID %d in project ID %d" , environmentId , projectId )
53
+ environmentResponse .Data .Environment_Id = & environmentId
54
+ return & environmentResponse .Data , nil
59
55
}
60
56
61
57
func (c * Client ) CreateEnvironment (isActive bool , projectId int , name string , dbtVersion string , type_ string , useCustomBranch bool , customBranch string , credentialId int ) (* Environment , error ) {
@@ -110,7 +106,7 @@ func (c *Client) UpdateEnvironment(projectId int, environmentId int, environment
110
106
return nil , err
111
107
}
112
108
113
- req , err := http .NewRequest ("POST" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/%d" , HostURL , c .AccountID , projectId , environmentId ), strings .NewReader (string (environmentData )))
109
+ req , err := http .NewRequest ("POST" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/%d/ " , HostURL , c .AccountID , projectId , environmentId ), strings .NewReader (string (environmentData )))
114
110
if err != nil {
115
111
return nil , err
116
112
}
@@ -131,7 +127,7 @@ func (c *Client) UpdateEnvironment(projectId int, environmentId int, environment
131
127
}
132
128
133
129
func (c * Client ) DeleteEnvironment (projectId , environmentId int ) (string , error ) {
134
- req , err := http .NewRequest ("DELETE" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/%d" , HostURL , c .AccountID , projectId , environmentId ), nil )
130
+ req , err := http .NewRequest ("DELETE" , fmt .Sprintf ("%s/v3/accounts/%d/projects/%d/environments/%d/ " , HostURL , c .AccountID , projectId , environmentId ), nil )
135
131
if err != nil {
136
132
return "" , err
137
133
}
0 commit comments