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

Missing Create Identity-provider API #67

Open
Raghavsalotra opened this issue May 17, 2022 · 3 comments
Open

Missing Create Identity-provider API #67

Raghavsalotra opened this issue May 17, 2022 · 3 comments

Comments

@Raghavsalotra
Copy link

Is there a way to create identity-provider using golang client. I don't see any implementation in client.go for creating one.

@mooreds
Copy link
Contributor

mooreds commented May 17, 2022

Hmmm. I don't think so. It looks like that operation is explicitly not created due to complexities around the JSON mapping: https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/go.client.ftl#L186

Two options you might explore:

@michaelholtermann
Copy link

I stumble across this limitation right now. I would assume if I can call the API on my own, it should be possible to integrate the API into the go-client, shouldn't it?

Maybe it's not possible to auto-generate it from the spec, but then it would be possible to add it manually?

@michaelholtermann
Copy link

Something like this for OIDC providers:

// There's no Create or Update API in the FusionAuthClient, see https://github.com/FusionAuth/go-client/issues/67
func createIdentityProvider(c service.LqtAuthClient, idP fusionauth.OpenIdConnectIdentityProvider) (*fusionauth.IdentityProviderResponse, *fusionauth.Errors, error) {
	var resp fusionauth.IdentityProviderResponse
	var errors fusionauth.Errors

	restClient := c.FusionAuthClient.Start(&resp, &errors)
	err := restClient.WithUri("/api/identity-provider").
		WithJSONBody(map[string]interface{}{"identityProvider": idP}).
		WithMethod(http.MethodPost).
		Do(context.TODO())

	return &resp, &errors, err
}

// There's no Create or Update API in the FusionAuthClient, see https://github.com/FusionAuth/go-client/issues/67
func updateIdentityProvider(c service.LqtAuthClient, idP fusionauth.OpenIdConnectIdentityProvider) (*fusionauth.IdentityProviderResponse, *fusionauth.Errors, error) {
	var resp fusionauth.IdentityProviderResponse
	var errors fusionauth.Errors

	restClient := c.FusionAuthClient.Start(&resp, &errors)
	err := restClient.WithUri("/api/identity-provider").
		WithJSONBody(map[string]interface{}{"identityProvider": idP}).
		WithMethod(http.MethodPut).
		WithUriSegment(idP.Id).
		Do(context.TODO())

	return &resp, &errors, err
}

It's not perfect, but fits my needs ATM.

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

No branches or pull requests

3 participants