-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add API calls for configuration set assignment (#857)
- Loading branch information
1 parent
e37247b
commit dbeba01
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -21,3 +21,6 @@ attic | |
.vscode/ | ||
.idea/ | ||
tf | ||
|
||
# macosx | ||
.DS_Store |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func (client *ApiClient) AssignConfigurationSets(scope string, scopeId string, sets []string) error { | ||
setIds := strings.Join(sets, ",") | ||
url := fmt.Sprintf("/configuration-sets/assignments/%s/%s?setIds=%s", scope, scopeId, setIds) | ||
|
||
return client.http.Post(url, nil, nil) | ||
} | ||
|
||
func (client *ApiClient) UnassignConfigurationSets(scope string, scopeId string, sets []string) error { | ||
setIds := strings.Join(sets, ",") | ||
url := fmt.Sprintf("/configuration-sets/assignments/%s/%s", scope, scopeId) | ||
|
||
return client.http.Delete(url, map[string]string{"setIds": setIds}) | ||
} |
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,31 @@ | ||
package client_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
) | ||
|
||
var _ = Describe("Configuration Set", func() { | ||
scope := "environment" | ||
scopeId := "12345" | ||
setIds := []string{"1", "2", "3"} | ||
|
||
Describe("assign configuration sets", func() { | ||
BeforeEach(func() { | ||
httpCall = mockHttpClient.EXPECT().Post("/configuration-sets/assignments/environment/12345?setIds=1,2,3", nil, nil).Times(1) | ||
apiClient.AssignConfigurationSets(scope, scopeId, setIds) | ||
}) | ||
|
||
It("Should send post request", func() {}) | ||
}) | ||
|
||
Describe("unassign configuration sets", func() { | ||
BeforeEach(func() { | ||
httpCall = mockHttpClient.EXPECT().Delete("/configuration-sets/assignments/environment/12345", map[string]string{ | ||
"setIds": "1,2,3", | ||
}).Times(1) | ||
apiClient.UnassignConfigurationSets(scope, scopeId, setIds) | ||
}) | ||
|
||
It("Should send delete request", func() {}) | ||
}) | ||
}) |