-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: Implemented additional REST API methods #6
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package connect | ||
|
||
import "net/http" | ||
|
||
// Plugin represents a Kafka Connect connector plugin | ||
type Plugin struct { | ||
Class string `json:"class"` | ||
Type string `json:"type"` | ||
Version string `json:"version"` | ||
} | ||
|
||
// ListPlugins retrieves a list of the installed plugins. | ||
// | ||
// See: https://docs.confluent.io/current/connect/references/restapi.html#get--connector-plugins- | ||
func (c *Client) ListPlugins() ([]*Plugin, *http.Response, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to return Also, I think I'd go with |
||
path := "connector-plugins" | ||
var names []*Plugin | ||
|
||
response, err := c.get(path, &names) | ||
return names, response, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package connect_test | ||
|
||
import ( | ||
"net/http" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/ghttp" | ||
|
||
. "github.com/go-kafka/connect" | ||
) | ||
|
||
var _ = Describe("Plugins Tests", func() { | ||
BeforeEach(func() { | ||
server = ghttp.NewServer() | ||
client = NewClient(server.URL()) | ||
}) | ||
|
||
AfterEach(func() { | ||
server.Close() | ||
}) | ||
|
||
Describe("ListPlugins", func() { | ||
var statusCode int | ||
resultPlugins := []*Plugin{ | ||
&Plugin{ | ||
Class: "test-class", | ||
Type: "source", | ||
Version: "5.3.0", | ||
}, | ||
} | ||
|
||
BeforeEach(func() { | ||
statusCode = http.StatusOK | ||
|
||
server.AppendHandlers( | ||
ghttp.CombineHandlers( | ||
ghttp.VerifyRequest("GET", "/connector-plugins"), | ||
ghttp.VerifyHeader(jsonAcceptHeader), | ||
ghttp.RespondWithJSONEncodedPtr(&statusCode, &resultPlugins), | ||
), | ||
) | ||
}) | ||
|
||
It("returns list of connector plugins", func() { | ||
plugins, _, err := client.ListPlugins() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(plugins).To(Equal(resultPlugins)) | ||
}) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, could these methods take a
TaskID
as single argument, instead of the weaker constituent basic types?