Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate tag rename (PUT /v2/tags/:name) #138

Merged
merged 1 commit into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type TagsService interface {
List(context.Context, *ListOptions) ([]Tag, *Response, error)
Get(context.Context, string) (*Tag, *Response, error)
Create(context.Context, *TagCreateRequest) (*Tag, *Response, error)
Update(context.Context, string, *TagUpdateRequest) (*Response, error)
Delete(context.Context, string) (*Response, error)

TagResources(context.Context, string, *TagResourcesRequest) (*Response, error)
Expand Down Expand Up @@ -65,11 +64,6 @@ type TagCreateRequest struct {
Name string `json:"name"`
}

//TagUpdateRequest represents the JSON structure of a request of that type.
type TagUpdateRequest struct {
Name string `json:"name"`
}

// TagResourcesRequest represents the JSON structure of a request of that type.
type TagResourcesRequest struct {
Resources []Resource `json:"resources"`
Expand Down Expand Up @@ -153,27 +147,6 @@ func (s *TagsServiceOp) Create(ctx context.Context, createRequest *TagCreateRequ
return root.Tag, resp, err
}

// Update an exsting tag
func (s *TagsServiceOp) Update(ctx context.Context, name string, updateRequest *TagUpdateRequest) (*Response, error) {
if name == "" {
return nil, NewArgError("name", "cannot be empty")
}

if updateRequest == nil {
return nil, NewArgError("updateRequest", "cannot be nil")
}

path := fmt.Sprintf("%s/%s", tagsBasePath, name)
req, err := s.client.NewRequest(ctx, "PUT", path, updateRequest)
if err != nil {
return nil, err
}

resp, err := s.client.Do(req, nil)

return resp, err
}

// Delete an existing tag
func (s *TagsServiceOp) Delete(ctx context.Context, name string) (*Response, error) {
if name == "" {
Expand Down
31 changes: 1 addition & 30 deletions tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var (
}
],
"links": {
"pages":{
"pages":{
"next":"http://example.com/v2/tags/?page=3",
"prev":"http://example.com/v2/tags/?page=1",
"last":"http://example.com/v2/tags/?page=3",
Expand Down Expand Up @@ -282,35 +282,6 @@ func TestTags_Create(t *testing.T) {
}
}

func TestTags_Update(t *testing.T) {
setup()
defer teardown()

updateRequest := &TagUpdateRequest{
Name: "testing-1",
}

mux.HandleFunc("/v2/tags/old-testing-1", func(w http.ResponseWriter, r *http.Request) {
v := new(TagUpdateRequest)

err := json.NewDecoder(r.Body).Decode(v)
if err != nil {
t.Fatalf("decode json: %v", err)
}

testMethod(t, r, "PUT")
if !reflect.DeepEqual(v, updateRequest) {
t.Errorf("Request body = %+v, expected %+v", v, updateRequest)
}

})

_, err := client.Tags.Update(ctx, "old-testing-1", updateRequest)
if err != nil {
t.Errorf("Tags.Update returned error: %v", err)
}
}

func TestTags_Delete(t *testing.T) {
setup()
defer teardown()
Expand Down