-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
281 additions
and
114 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
vendor/ | ||
terraform-provider* | ||
env.vars | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package lightdash | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type Project struct { | ||
ProjectUUID string `json:"projectUuid,omitempty"` | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
type ProjectResponse struct { | ||
Results Project `json:"results"` | ||
Status string `json:"status"` | ||
} | ||
|
||
type ProjectsResponse struct { | ||
Results []Project `json:"results"` | ||
Status string `json:"status"` | ||
} | ||
|
||
func (c *Client) GetProject(projectUUID string) (*Project, error) { | ||
req, err := http.NewRequest("GET", fmt.Sprintf("%s/org/projects", c.ApiURL), nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
body, err, _ := c.doRequest(req) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
projectsResponse := ProjectsResponse{} | ||
err = json.Unmarshal(body, &projectsResponse) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for i, project := range projectsResponse.Results { | ||
if project.ProjectUUID == projectUUID { | ||
return &projectsResponse.Results[i], nil | ||
} | ||
} | ||
|
||
return nil, fmt.Errorf("Project not found UUID %s", projectUUID) | ||
} | ||
|
||
// func (c *Client) CreateProject(name string) (*Project, error) { | ||
// | ||
// return &newProject, nil | ||
// } | ||
// | ||
// func (c *Client) UpdateProject(projectUUID string) (*Project, error) { | ||
// | ||
// return &projectResponse.Results, nil | ||
// } | ||
|
||
func (c *Client) DeleteProject(projectUUID string) (string, error) { | ||
req, err := http.NewRequest("DELETE", fmt.Sprintf("%s/org/projects/%s", c.ApiURL, projectUUID), nil) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
body, err, _ := c.doRequest(req) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
projectResponse := ProjectResponse{} | ||
err = json.Unmarshal(body, &projectResponse) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return projectResponse.Status, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.