Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Implement Generic() func on Client #335

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gprossliner
Copy link

This PR allows to call any API that is not (yet) implemented by the module itself, like "/authz/shares":

func shareStream(context context.Context, streamID string, userID string)  error
{
	request := struct {
		Selected_grantee_capabilities map[string]interface{} `json:"selected_grantee_capabilities"`
	}{map[string]interface{}{
		"grn::::user:" + userID: "view",
	}}

	grn := "grn::::stream:" + streamID
	_, err = client.Generic(ctx, http.MethodPost, "/authz/shares/entities/"+grn, request, nil)
	return err
}

To make my fork build successfully, I had to execute go mod tidy.
I did not commit the resulting changes to go.sum to avoid merge-conflicts.

I tried to keep the coding-style like the existing files.

I added unit-tests for the constructing the Endpoint URL, but no integration tests incl. Mock-Server.
Please let me know if you are interested in merging this PR, than I can implement these as well.

This was referenced May 17, 2021
@m-barthelemy
Copy link

Would this PR help for #332 ?
Will it get merged?

@gprossliner
Copy link
Author

Hi! This would not implement #332 directly, but allow the user to call it, or any other / furture API methods not directly implemented in go-graylog.

Because I got no answer on this PR or #322 issue, I did not proceed further. To avoid implementing this totally twice (one by the go-graylog client, and once by just http.Client, I copied the Source files into my project, and use the "Generic" Implementation from this PR.

Nevertheless I would like to get this merged, or at least some feedback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants