Skip to content

Commit d80b289

Browse files
committed
Compute V2: rename Tags Replace to ReplaceAll
Use ReplaceAll name like it's done in networking extension.t
1 parent dc517c6 commit d80b289

6 files changed

Lines changed: 22 additions & 22 deletions

File tree

openstack/compute/v2/extensions/tags/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Example to Replace all Tags on a server
3333
3434
client.Microversion = "2.62"
3535
36-
newTags, err := tags.Replace(client, serverID, tags. tags.ReplaceOpts{Tags: []string{"foo", "bar"}}).Extract()
36+
newTags, err := tags.ReplaceAll(client, serverID, tags. tags.ReplaceAllOpts{Tags: []string{"foo", "bar"}}).Extract()
3737
if err != nil {
3838
log.Fatal(err)
3939
}

openstack/compute/v2/extensions/tags/requests.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,25 @@ func Check(client *gophercloud.ServiceClient, serverID, tag string) (r CheckResu
2020
return
2121
}
2222

23-
// ReplaceOptsBuilder allows to add additional parameters to the Replace request.
24-
type ReplaceOptsBuilder interface {
25-
ToTagsReplaceMap() (map[string]interface{}, error)
23+
// ReplaceAllOptsBuilder allows to add additional parameters to the ReplaceAll request.
24+
type ReplaceAllOptsBuilder interface {
25+
ToTagsReplaceAllMap() (map[string]interface{}, error)
2626
}
2727

28-
// ReplaceOpts provides options used to replace Tags on a server.
29-
type ReplaceOpts struct {
28+
// ReplaceAllOpts provides options used to replace Tags on a server.
29+
type ReplaceAllOpts struct {
3030
Tags []string `json:"tags" required:"true"`
3131
}
3232

33-
// ToTagsReplaceMap formats a ReplaceOpts into the body of the replace request.
34-
func (opts ReplaceOpts) ToTagsReplaceMap() (map[string]interface{}, error) {
33+
// ToTagsReplaceAllMap formats a ReplaceALlOpts into the body of the ReplaceAll request.
34+
func (opts ReplaceAllOpts) ToTagsReplaceAllMap() (map[string]interface{}, error) {
3535
return gophercloud.BuildRequestBody(opts, "")
3636
}
3737

38-
// Replace replaces all tags on a server.
39-
func Replace(client *gophercloud.ServiceClient, serverID string, opts ReplaceOptsBuilder) (r ReplaceResult) {
40-
b, err := opts.ToTagsReplaceMap()
41-
url := replaceURL(client, serverID)
38+
// ReplaceAll replaces all tags on a server.
39+
func ReplaceAll(client *gophercloud.ServiceClient, serverID string, opts ReplaceAllOptsBuilder) (r ReplaceAllResult) {
40+
b, err := opts.ToTagsReplaceAllMap()
41+
url := replaceAllURL(client, serverID)
4242
if err != nil {
4343
r.Err = err
4444
return

openstack/compute/v2/extensions/tags/results.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (r CheckResult) Extract() (bool, error) {
3636
return exists, r.Err
3737
}
3838

39-
// ReplaceResult is the result from the Replace operation.
40-
type ReplaceResult struct {
39+
// ReplaceAllResult is the result from the ReplaceAll operation.
40+
type ReplaceAllResult struct {
4141
commonResult
4242
}

openstack/compute/v2/extensions/tags/testing/fixtures.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ const TagsListResponse = `
77
}
88
`
99

10-
// TagsReplaceRequest represents a raw tags Replace request.
11-
const TagsReplaceRequest = `
10+
// TagsReplaceAllRequest represents a raw tags Replace request.
11+
const TagsReplaceAllRequest = `
1212
{
1313
"tags": ["tag1", "tag2", "tag3"]
1414
}
1515
`
1616

17-
// TagsReplaceResponse represents a raw tags Replace response.
18-
const TagsReplaceResponse = `
17+
// TagsReplaceAllResponse represents a raw tags Replace response.
18+
const TagsReplaceAllResponse = `
1919
{
2020
"tags": ["tag1", "tag2", "tag3"]
2121
}

openstack/compute/v2/extensions/tags/testing/requests_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestCheckFail(t *testing.T) {
6666
th.AssertEquals(t, false, exists)
6767
}
6868

69-
func TestReplace(t *testing.T) {
69+
func TestReplaceAll(t *testing.T) {
7070
th.SetupHTTP()
7171
defer th.TeardownHTTP()
7272

@@ -77,12 +77,12 @@ func TestReplace(t *testing.T) {
7777
w.Header().Add("Content-Type", "application/json")
7878
w.WriteHeader(http.StatusOK)
7979

80-
_, err := fmt.Fprintf(w, TagsReplaceResponse)
80+
_, err := fmt.Fprintf(w, TagsReplaceAllResponse)
8181
th.AssertNoErr(t, err)
8282
})
8383

8484
expected := []string{"tag1", "tag2", "tag3"}
85-
actual, err := tags.Replace(client.ServiceClient(), "uuid1", tags.ReplaceOpts{Tags: []string{"tag1", "tag2", "tag3"}}).Extract()
85+
actual, err := tags.ReplaceAll(client.ServiceClient(), "uuid1", tags.ReplaceAllOpts{Tags: []string{"tag1", "tag2", "tag3"}}).Extract()
8686

8787
th.AssertNoErr(t, err)
8888
th.AssertDeepEquals(t, expected, actual)

openstack/compute/v2/extensions/tags/urls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ func checkURL(c *gophercloud.ServiceClient, serverID, tag string) string {
2323
return resourceURL(c, serverID, tag)
2424
}
2525

26-
func replaceURL(c *gophercloud.ServiceClient, serverID string) string {
26+
func replaceAllURL(c *gophercloud.ServiceClient, serverID string) string {
2727
return rootURL(c, serverID)
2828
}

0 commit comments

Comments
 (0)