From 2f4c9ca7af4f9ce06beb1ed25006c8cf297dce42 Mon Sep 17 00:00:00 2001 From: Mike Chittenden Date: Fri, 7 Apr 2017 10:53:34 -0400 Subject: [PATCH] Deprecate tag rename (PUT /v2/tags/:name) --- tags.go | 27 --------------------------- tags_test.go | 31 +------------------------------ 2 files changed, 1 insertion(+), 57 deletions(-) diff --git a/tags.go b/tags.go index 709e96c..3918644 100644 --- a/tags.go +++ b/tags.go @@ -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) @@ -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"` @@ -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 == "" { diff --git a/tags_test.go b/tags_test.go index 0ced656..677cb37 100644 --- a/tags_test.go +++ b/tags_test.go @@ -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", @@ -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()