-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
package keto | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/ory/keto/sdk/go/keto/swagger" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
type SDK interface { | ||
RoleSDK | ||
WardenSDK | ||
PolicySDK | ||
} | ||
|
||
type CodeGenSDK struct { | ||
*swagger.RoleApi | ||
*swagger.WardenApi | ||
*swagger.PolicyApi | ||
|
||
Configuration *Configuration | ||
} | ||
|
||
// Configuration configures the CodeGenSDK. | ||
type Configuration struct { | ||
// EndpointURL should point to the url of ORY Hydra, for example: http://localhost:4444 | ||
EndpointURL string | ||
} | ||
|
||
// CodeGenSDK instantiates a new CodeGenSDK instance or returns an error. | ||
func NewCodeGenSDK(c *Configuration) (*CodeGenSDK, error) { | ||
if c.EndpointURL == "" { | ||
return nil, errors.New("Please specify the ORY Keto endpoint URL") | ||
} | ||
|
||
c.EndpointURL = strings.TrimRight(c.EndpointURL, "/") | ||
sdk := &CodeGenSDK{ | ||
RoleApi: swagger.NewRoleApiWithBasePath(c.EndpointURL), | ||
WardenApi: swagger.NewWardenApiWithBasePath(c.EndpointURL), | ||
PolicyApi: swagger.NewPolicyApiWithBasePath(c.EndpointURL), | ||
} | ||
|
||
return sdk, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters