-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add draft workspace settings * added postprocessing and build scripts * add recommended extension * organised generate files * update makefile generate task * makefile updates * readme * readme update
- Loading branch information
1 parent
4e5793e
commit c0ea22c
Showing
35 changed files
with
1,130 additions
and
555 deletions.
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
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,2 +1,90 @@ | ||
# pingone-go-sdk-v2 | ||
# PingOne Administration GO SDK | ||
|
||
The PingOne GO SDK provides a set of functions and stucts that help with interacting with the PingOne public cloud API. | ||
|
||
The code is intended to be delivered as a sample, until an official GO SDK is released from Ping Identity. As such, the code is highly likely to change significantly between releases. | ||
|
||
Code for each service is generated with the help of the [OpenAPI Generator](https://openapi-generator.tech/). | ||
|
||
## Packages | ||
|
||
The SDK provides a core package, and a package per PingOne service, each with their own directory off the root of the project: | ||
|
||
* **agreementmanagement** for the PingOne end-user agreements managements service | ||
* **authorize** for the PingOne Authorize service | ||
* **credentials** for the PingOne Credentials service, part of PingOne Neo | ||
* **management** for the PingOne platform common and SSO services | ||
* **mfa** for the PingOne MFA service | ||
* **risk** for the PingOne Protect service | ||
* **verify** for the PingOne Verify service, part of PingOne Neo | ||
|
||
## Getting Started | ||
|
||
The client can be invoked using the following syntax: | ||
|
||
```go | ||
|
||
... | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/patrickcping/pingone-go-sdk-v2/pingone" | ||
) | ||
|
||
... | ||
|
||
config := &pingone.Config{ | ||
ClientID: clientId, | ||
ClientSecret: clientSecret, | ||
EnvironmentID: environmentId, | ||
AccessToken: accessToken, | ||
Region: region, | ||
} | ||
|
||
client, err := config.APIClient(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
``` | ||
|
||
The result is an object with clients initialised for each service: | ||
* `client.AgreementManagementAPIClient` | ||
* `client.AuthorizeAPIClient` | ||
* `client.CredentialsAPIClient` | ||
* `client.ManagementAPIClient` | ||
* `client.MFAAPIClient` | ||
* `client.RiskAPIClient` | ||
* `client.VerifyAPIClient` | ||
|
||
In the above, if an `AccessToken` is provided, this will be verified and used. If the `AccessToken` is not provided, the SDK will retrieve an access token from the provided `ClientID`, `ClientSecret`, `EnvironmentID` and `Region` parameters. | ||
|
||
The client SDK defaults to production hostnames, and the `Region` is used to add the relevant suffix to the hostname. For example, `Europe` as a `Region` value with suffix the service hostname with `.eu`. Hostnames can be overridden with the optional `APIHostnameOverride`, `AgreementMgmtHostnameOverride`, and `AuthHostnameOverride` parameters. | ||
|
||
An API call can be made against the API objects, as in the following example to get all environments in a tenant: | ||
|
||
```go | ||
... | ||
|
||
resp, r, err := client.ManagementAPIClient.EnvironmentsApi.ReadAllEnvironments(ctx).Execute() | ||
if err != nil { | ||
return nil, err | ||
} | ||
... | ||
``` | ||
|
||
## Contributing | ||
|
||
Each package is generated from an underlying OpenAPI 3 specification. Currently the OpenAPI 3 specification is stored in the `./<<module>>/generate/pingone-<<module>>.yml` file, although this will be subject to change in the future. | ||
|
||
* [**agreementmanagement** OpenAPI 3 Specification file](./authorize/generate/pingone-authorize.yml) | ||
* [**authorize** OpenAPI 3 Specification file](./authorize/generate/pingone-authorize.yml) | ||
* [**credentials** OpenAPI 3 Specification file](./credentials/generate/pingone-credentials.yml) | ||
* [**management** OpenAPI 3 Specification file](./management/generate/pingone-management.yml) | ||
* [**mfa** OpenAPI 3 Specification file](./mfa/generate/pingone-mfa.yml) | ||
* [**risk** OpenAPI 3 Specification file](./risk/generate/pingone-risk.yml) | ||
* [**verify** OpenAPI 3 Specification file](./verify/generate/pingone-verify.yml) | ||
|
||
Once this file has been updated, from the module directory itself run `make generate`. This will generate the required `api_*.go` files, `model_*.go` files and associated documentation. | ||
|
||
Before raising a Pull request, the resulting code can be checked using the `make devcheck` command. This will build, lint and verify the code. |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -29,5 +29,6 @@ CHANGELOG.md | |
GNUmakefile | ||
.version | ||
test/* | ||
generate/ | ||
|
||
client.go |
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
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
agreementmanagement/generate/postprocessing/generate-replace-regex.go
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
) | ||
|
||
func main() { | ||
// Get the target directory from the command line argument | ||
if len(os.Args) < 2 { | ||
println("Usage: go run script.go <directory>") | ||
return | ||
} | ||
dir := os.Args[1] | ||
|
||
for _, rule := range replaceRules { | ||
// Get a list of all files with the given extension in the directory | ||
files, err := filepath.Glob(filepath.Join(dir, rule.fileSelectPattern)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Iterate over the files and apply the regex replacement rules | ||
for _, file := range files { | ||
// Read the file contents | ||
content, err := os.ReadFile(filepath.Clean(file)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Apply the regex replacement rule | ||
re := regexp.MustCompile(rule.pattern) | ||
content = re.ReplaceAll(content, []byte(rule.repl)) | ||
|
||
// Write the updated file contents | ||
err = os.WriteFile(file, content, os.ModePerm) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
} | ||
|
||
var ( | ||
// Define the full list of regex replacement rules | ||
replaceRules = []struct { | ||
fileSelectPattern string | ||
pattern string | ||
repl string | ||
}{} | ||
) |
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 |
---|---|---|
|
@@ -29,5 +29,6 @@ CHANGELOG.md | |
GNUmakefile | ||
.version | ||
test/* | ||
generate/* | ||
|
||
client.go |
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
File renamed without changes.
52 changes: 52 additions & 0 deletions
52
authorize/generate/postprocessing/generate-replace-regex.go
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
) | ||
|
||
func main() { | ||
// Get the target directory from the command line argument | ||
if len(os.Args) < 2 { | ||
println("Usage: go run script.go <directory>") | ||
return | ||
} | ||
dir := os.Args[1] | ||
|
||
for _, rule := range replaceRules { | ||
// Get a list of all files with the given extension in the directory | ||
files, err := filepath.Glob(filepath.Join(dir, rule.fileSelectPattern)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Iterate over the files and apply the regex replacement rules | ||
for _, file := range files { | ||
// Read the file contents | ||
content, err := os.ReadFile(filepath.Clean(file)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Apply the regex replacement rule | ||
re := regexp.MustCompile(rule.pattern) | ||
content = re.ReplaceAll(content, []byte(rule.repl)) | ||
|
||
// Write the updated file contents | ||
err = os.WriteFile(file, content, os.ModePerm) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
} | ||
|
||
var ( | ||
// Define the full list of regex replacement rules | ||
replaceRules = []struct { | ||
fileSelectPattern string | ||
pattern string | ||
repl string | ||
}{} | ||
) |
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 |
---|---|---|
|
@@ -29,5 +29,6 @@ CHANGELOG.md | |
GNUmakefile | ||
.version | ||
test/* | ||
generate/* | ||
|
||
client.go |
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
File renamed without changes.
Oops, something went wrong.