diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..e6a9944 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.go linguist-generated=false \ No newline at end of file diff --git a/README.md b/README.md index 9658714..e0d47f1 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,16 @@ Development happens in the [GitHub repo](https://github.com/abbeylabs/terraform- This project is licensed under the MPL 2.0 license. See [LICENSE](LICENSE) for more details. + + + + + + + + + + + + + diff --git a/RELEASES.md b/RELEASES.md index 3da5c30..d26075f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -82,4 +82,216 @@ Based on: ### Changes Based on: - OpenAPI Doc v1 -- Speakeasy CLI 1.65.2 (2.75.1) https://github.com/speakeasy-api/speakeasy \ No newline at end of file +- Speakeasy CLI 1.65.2 (2.75.1) https://github.com/speakeasy-api/speakeasy + +## 2023-08-05 00:04:08 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.68.3 (2.81.1) https://github.com/speakeasy-api/speakeasy + +## 2023-08-08 00:04:01 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.69.1 (2.82.0) https://github.com/speakeasy-api/speakeasy + +## 2023-08-09 00:04:04 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.70.2 (2.83.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.5.0] . + +## 2023-08-16 00:04:13 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.73.1 (2.84.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.6.0] . + +## 2023-08-19 00:03:50 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.74.3 (2.86.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.6.1] . + +## 2023-08-24 00:03:59 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.74.9 (2.86.10) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.6.2] . + +## 2023-08-25 00:04:00 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.74.11 (2.87.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.6.3] . + +## 2023-08-26 00:03:50 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.74.15 (2.88.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.7.0] . + +## 2023-08-31 00:04:01 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.75.0 (2.89.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.8.0] . + +## 2023-09-01 00:04:43 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.77.0 (2.91.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.9.0] . + +## 2023-09-02 00:04:10 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.77.1 (2.91.4) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.9.1] . + +## 2023-09-03 00:04:39 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.77.2 (2.93.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.9.2] . + +## 2023-09-05 00:04:29 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.78.3 (2.96.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.9.3] . + +## 2023-09-07 00:04:24 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.79.0 (2.101.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.9.4] . + +## 2023-09-08 00:04:22 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.82.0 (2.107.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.0] . + +## 2023-09-09 00:04:24 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.82.3 (2.107.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.1] . + +## 2023-09-12 00:04:32 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.82.5 (2.108.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.2] . + +## 2023-09-16 00:04:22 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.86.0 (2.115.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.3] . + +## 2023-09-20 00:04:36 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.88.0 (2.118.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.4] . + +## 2023-09-21 00:04:34 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.88.1 (2.122.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.10.5] . + +## 2023-09-26 00:04:35 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.91.0 (2.129.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.11.0] . + +## 2023-09-27 00:04:36 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.91.2 (2.131.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.11.1] . + +## 2023-09-29 00:04:41 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.91.3 (2.139.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.12.0] . + +## 2023-10-01 00:05:03 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.92.2 (2.142.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.13.0] . + +## 2023-10-03 00:04:40 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.93.1 (2.144.7) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.14.0] . + +## 2023-10-07 00:04:25 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.96.1 (2.150.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.14.1] . + +## 2023-10-08 00:04:46 +### Changes +Based on: +- OpenAPI Doc v1 +- Speakeasy CLI 1.96.1 (2.150.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v2.14.2] . \ No newline at end of file diff --git a/examples/data-sources/abbey_grant_kit/data-source.tf b/examples/data-sources/abbey_grant_kit/data-source.tf new file mode 100755 index 0000000..cf0248d --- /dev/null +++ b/examples/data-sources/abbey_grant_kit/data-source.tf @@ -0,0 +1,3 @@ +data "abbey_grant_kit" "my_grantkit" { + id = "599f5bb1-790c-46d8-9bb6-a138242e4faa" +} \ No newline at end of file diff --git a/examples/data-sources/abbey_identity/data-source.tf b/examples/data-sources/abbey_identity/data-source.tf new file mode 100755 index 0000000..cca117d --- /dev/null +++ b/examples/data-sources/abbey_identity/data-source.tf @@ -0,0 +1,3 @@ +data "abbey_identity" "my_identity" { + id = "d5a7ff55-fca7-4a36-b098-713e8a9a975d" +} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 5fe44af..c1f1e6c 100755 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,12 +2,11 @@ terraform { required_providers { abbey = { source = "abbeylabs/abbey" - version = "0.2.4" + version = "2.14.2" } } } provider "abbey" { # Configuration options - bearer_auth = "" } \ No newline at end of file diff --git a/examples/resources/abbey_demo/resource.tf b/examples/resources/abbey_demo/resource.tf index 73f913a..400ea2f 100755 --- a/examples/resources/abbey_demo/resource.tf +++ b/examples/resources/abbey_demo/resource.tf @@ -1,4 +1,4 @@ resource "abbey_demo" "my_demo" { + email = "Maye_Hagenes35@gmail.com" permission = "read_write" - email = "alice@example.com" } \ No newline at end of file diff --git a/examples/resources/abbey_grant_kit/resource.tf b/examples/resources/abbey_grant_kit/resource.tf index 7cf40c5..dd7fd60 100755 --- a/examples/resources/abbey_grant_kit/resource.tf +++ b/examples/resources/abbey_grant_kit/resource.tf @@ -1,36 +1,35 @@ -resource "abbey_grant_kit" "my_grant_kit" { - name = "my_grant_kit" - description = "My description." - +resource "abbey_grant_kit" "my_grantkit" { + description = "...my_description..." + name = "Jaime Kunde" + output = { + append = "...my_append..." + location = "...my_location..." + overwrite = "...my_overwrite..." + } + policies = [ + { + bundle = "...my_bundle..." + query = "...my_query..." + }, + ] workflow = { steps = [ { reviewers = { - one_of = ["alice@example.com"] - } - }, - { - reviewers = { - all_of = ["bob@example.com", "carol@example.com"] + all_of = [ + "...", + ] + one_of = [ + "...", + ] } skip_if = [ - { bundle = "github://my-org/my-repo/policies/on-call-overrides" } + { + bundle = "...my_bundle..." + query = "...my_query..." + }, ] - } + }, ] } - - policies = [ - { bundle = "github://my-org/my-repo/policies/common" } - ] - - output = { - location = "github://my-org/my-repo/access.tf" - append = <<-EOT - resource "abbey_demo" "my_demo" { - permission = "read_write" - email = "alice@example.com" - } - EOT - } } \ No newline at end of file diff --git a/examples/resources/abbey_identity/resource.tf b/examples/resources/abbey_identity/resource.tf index 151f393..3d0070e 100755 --- a/examples/resources/abbey_identity/resource.tf +++ b/examples/resources/abbey_identity/resource.tf @@ -1,9 +1,5 @@ resource "abbey_identity" "my_identity" { - abbey_account = "alice@example.com" - source = "mysource" - metadata = jsonencode( - { - "mykey" = "myvalue" - } - ) + abbey_account = "...my_abbey_account..." + metadata = "...my_metadata..." + source = "...my_source..." } \ No newline at end of file diff --git a/files.gen b/files.gen index e261550..c912f10 100755 --- a/files.gen +++ b/files.gen @@ -1,12 +1,19 @@ internal/sdk/apikeys.go +internal/sdk/analytics.go internal/sdk/connectionspecs.go internal/sdk/connections.go internal/sdk/demo.go +internal/sdk/directorysync.go internal/sdk/grantkits.go internal/sdk/grants.go internal/sdk/identities.go +internal/sdk/oauth.go +internal/sdk/oauths.go internal/sdk/requests.go internal/sdk/reviews.go +internal/sdk/samlconnections.go +internal/sdk/slackcommand.go +internal/sdk/workos.go internal/sdk/sdk.go internal/provider/type_grant.go internal/provider/type_output.go @@ -66,14 +73,27 @@ tools/tools.go internal/sdk/pkg/models/operations/createapikey.go internal/sdk/pkg/models/operations/getapikeys.go internal/sdk/pkg/models/operations/deleteapikey.go +internal/sdk/pkg/models/operations/countapprovalsbyuser.go +internal/sdk/pkg/models/operations/countgrantkitsfororganization.go +internal/sdk/pkg/models/operations/countrequestsbyresourcefororg.go internal/sdk/pkg/models/operations/listconnectionspecs.go internal/sdk/pkg/models/operations/createconnection.go +internal/sdk/pkg/models/operations/creategheapp.go +internal/sdk/pkg/models/operations/deletegheapp.go internal/sdk/pkg/models/operations/getconnection.go +internal/sdk/pkg/models/operations/getgheapp.go internal/sdk/pkg/models/operations/listconnections.go +internal/sdk/pkg/models/operations/listgheapp.go internal/sdk/pkg/models/operations/updateconnection.go +internal/sdk/pkg/models/operations/updategheapp.go internal/sdk/pkg/models/operations/createdemo.go internal/sdk/pkg/models/operations/deletedemo.go internal/sdk/pkg/models/operations/getdemo.go +internal/sdk/pkg/models/operations/createdirectory.go +internal/sdk/pkg/models/operations/deletedirectory.go +internal/sdk/pkg/models/operations/getdirectory.go +internal/sdk/pkg/models/operations/getportallink.go +internal/sdk/pkg/models/operations/updatedirectory.go internal/sdk/pkg/models/operations/creategrantkit.go internal/sdk/pkg/models/operations/listgrantkits.go internal/sdk/pkg/models/operations/deletegrantkit.go @@ -86,7 +106,10 @@ internal/sdk/pkg/models/operations/revokegrant.go internal/sdk/pkg/models/operations/createidentity.go internal/sdk/pkg/models/operations/deleteidentity.go internal/sdk/pkg/models/operations/getidentity.go +internal/sdk/pkg/models/operations/listenrichedidentities.go internal/sdk/pkg/models/operations/updateidentity.go +internal/sdk/pkg/models/operations/createoauth.go +internal/sdk/pkg/models/operations/listoauths.go internal/sdk/pkg/models/operations/cancelrequestbyid.go internal/sdk/pkg/models/operations/createrequest.go internal/sdk/pkg/models/operations/getrequestbyid.go @@ -95,15 +118,29 @@ internal/sdk/pkg/models/operations/listreviews.go internal/sdk/pkg/models/operations/approvereview.go internal/sdk/pkg/models/operations/denyreview.go internal/sdk/pkg/models/operations/getreviewbyid.go +internal/sdk/pkg/models/operations/createsamlconnection.go +internal/sdk/pkg/models/operations/deletesamlconnectionbyid.go +internal/sdk/pkg/models/operations/getsamlconnectionbyid.go +internal/sdk/pkg/models/operations/listsamlconnections.go +internal/sdk/pkg/models/operations/updatesamlconnectionbyid.go +internal/sdk/pkg/models/operations/slackcommand.go +internal/sdk/pkg/models/operations/workosdirectorieswebhook.go +internal/sdk/pkg/models/operations/workosgroupswebhook.go +internal/sdk/pkg/models/operations/workosuserswebhook.go internal/sdk/pkg/models/shared/error.go internal/sdk/pkg/models/shared/apikey.go internal/sdk/pkg/models/shared/apikeyscreateparams.go internal/sdk/pkg/models/shared/apikeys.go +internal/sdk/pkg/models/shared/userapprovalanalytics.go +internal/sdk/pkg/models/shared/userapprovalcount.go +internal/sdk/pkg/models/shared/organizationgrantkitcounts.go +internal/sdk/pkg/models/shared/organizationgrantkitcount.go +internal/sdk/pkg/models/shared/resourcerequestcounts.go +internal/sdk/pkg/models/shared/resourcerequestcount.go internal/sdk/pkg/models/shared/connectionspeclisting.go internal/sdk/pkg/models/shared/connectionspec.go internal/sdk/pkg/models/shared/connectionrequestspec.go internal/sdk/pkg/models/shared/connectionauth.go -internal/sdk/pkg/models/shared/oauth2flow.go internal/sdk/pkg/models/shared/keyvaluepair.go internal/sdk/pkg/models/shared/oauth2flowpkce.go internal/sdk/pkg/models/shared/pkcemethod.go @@ -115,14 +152,18 @@ internal/sdk/pkg/models/shared/connectionauthtypeenum.go internal/sdk/pkg/models/shared/connection.go internal/sdk/pkg/models/shared/connectiontype.go internal/sdk/pkg/models/shared/connectionparams.go -internal/sdk/pkg/models/shared/connectionparamsgithubvariant.go internal/sdk/pkg/models/shared/connectionparamsgithub.go -internal/sdk/pkg/models/shared/pagerdutyconnectionvalue.go internal/sdk/pkg/models/shared/pagerdutyconnection.go +internal/sdk/pkg/models/shared/githubenterpriseconnection.go +internal/sdk/pkg/models/shared/githubenterpriseapp.go +internal/sdk/pkg/models/shared/githubenterpriseappparams.go internal/sdk/pkg/models/shared/connectionlisting.go internal/sdk/pkg/models/shared/connectionupdateparams.go internal/sdk/pkg/models/shared/demo.go internal/sdk/pkg/models/shared/demoparams.go +internal/sdk/pkg/models/shared/directorysync.go +internal/sdk/pkg/models/shared/directorysyncparams.go +internal/sdk/pkg/models/shared/directorysyncadminportal.go internal/sdk/pkg/models/shared/grantkit.go internal/sdk/pkg/models/shared/grantworkflow.go internal/sdk/pkg/models/shared/step.go @@ -139,9 +180,25 @@ internal/sdk/pkg/models/shared/grantkitversion.go internal/sdk/pkg/models/shared/grantkitupdateparams.go internal/sdk/pkg/models/shared/identity.go internal/sdk/pkg/models/shared/identityparams.go +internal/sdk/pkg/models/shared/oauthcreateparams.go +internal/sdk/pkg/models/shared/oauthlisting.go +internal/sdk/pkg/models/shared/oauth.go internal/sdk/pkg/models/shared/requestcancelparams.go internal/sdk/pkg/models/shared/requestparams.go +internal/sdk/pkg/models/shared/userinput.go internal/sdk/pkg/models/shared/reviewupdateparams.go +internal/sdk/pkg/models/shared/samlconnection.go +internal/sdk/pkg/models/shared/samlconnectionparams.go +internal/sdk/pkg/models/shared/samlconnections.go +internal/sdk/pkg/models/shared/samlconnectionupdateparams.go +internal/sdk/pkg/models/shared/slackcommand.go +internal/sdk/pkg/models/shared/workosdirectoryevent.go +internal/sdk/pkg/models/shared/workosdirectorydata.go +internal/sdk/pkg/models/shared/workosgroupevent.go +internal/sdk/pkg/models/shared/workosgroupdata.go +internal/sdk/pkg/models/shared/workosuserdata.go +internal/sdk/pkg/models/shared/workosgroup.go +internal/sdk/pkg/models/shared/workosuserevent.go internal/sdk/pkg/models/shared/security.go USAGE.md internal/provider/provider.go @@ -154,4 +211,11 @@ internal/provider/grantkit_resource_sdk.go examples/resources/abbey_grant_kit/resource.tf internal/provider/identity_resource.go internal/provider/identity_resource_sdk.go -examples/resources/abbey_identity/resource.tf \ No newline at end of file +examples/resources/abbey_identity/resource.tf +internal/provider/grantkit_data_source.go +internal/provider/grantkit_data_source_sdk.go +examples/data-sources/abbey_grant_kit/data-source.tf +internal/provider/identity_data_source.go +internal/provider/identity_data_source_sdk.go +examples/data-sources/abbey_identity/data-source.tf +.gitattributes \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 56b6cfa..d3d12ea 100755 --- a/gen.yaml +++ b/gen.yaml @@ -1,13 +1,21 @@ configVersion: 1.0.0 management: - docChecksum: 73c07ff157bbd13199a5e11925950ef4 + docChecksum: c44ce96a3c08db742e90b436593018e0 docVersion: v1 - speakeasyVersion: 1.65.2 - generationVersion: 2.75.1 + speakeasyVersion: 1.96.1 + generationVersion: 2.150.0 generation: sdkClassName: SDK singleTagPerOp: false +features: + terraform: + core: 2.92.1 + globalSecurity: 2.81.1 + globalServerURLs: 2.82.0 + includes: 2.81.1 + nameOverrides: 2.81.1 + serverIDs: 2.81.1 terraform: - version: 2.2.1 + version: 2.14.2 author: abbeylabs packageName: abbey diff --git a/go.mod b/go.mod index 157417d..3d0bfde 100755 --- a/go.mod +++ b/go.mod @@ -3,61 +3,62 @@ module abbey/v2 go 1.18 require ( - github.com/cenkalti/backoff/v4 v4.2.0 - github.com/hashicorp/terraform-plugin-framework v1.3.0 - github.com/hashicorp/terraform-plugin-go v0.15.0 + github.com/cenkalti/backoff/v4 v4.2.0 + github.com/hashicorp/terraform-plugin-framework v1.3.5 + github.com/hashicorp/terraform-plugin-go v0.18.0 ) require ( - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig/v3 v3.2.2 // indirect - github.com/armon/go-radix v1.0.0 // indirect - github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/fatih/color v1.13.0 // indirect - github.com/golang/protobuf v1.5.2 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-checkpoint v0.5.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.4.9 // indirect - github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect - github.com/hashicorp/terraform-exec v0.17.2 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect - github.com/hashicorp/terraform-registry-address v0.2.0 // indirect - github.com/hashicorp/terraform-svchost v0.0.1 // indirect - github.com/huandu/xstrings v1.3.2 // indirect - github.com/imdario/mergo v0.3.13 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - github.com/mitchellh/cli v1.1.4 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/oklog/run v1.0.0 // indirect - github.com/posener/complete v1.2.3 // indirect - github.com/russross/blackfriday v1.6.0 // indirect - github.com/shopspring/decimal v1.3.1 // indirect - github.com/spf13/cast v1.5.0 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect - golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect - google.golang.org/grpc v1.54.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.2 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/armon/go-radix v1.0.0 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/fatih/color v1.13.0 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-checkpoint v0.5.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-plugin v1.4.10 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/hc-install v0.4.0 // indirect + github.com/hashicorp/terraform-exec v0.17.2 // indirect + github.com/hashicorp/terraform-json v0.14.0 // indirect + github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.1 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mitchellh/cli v1.1.4 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/oklog/run v1.0.0 // indirect + github.com/posener/complete v1.2.3 // indirect + github.com/russross/blackfriday v1.6.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/zclconf/go-cty v1.13.1 // indirect + golang.org/x/crypto v0.10.0 // indirect + golang.org/x/net v0.11.0 // indirect + golang.org/x/sys v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect + google.golang.org/grpc v1.56.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect ) require ( - github.com/hashicorp/terraform-plugin-docs v0.13.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 - github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect + github.com/hashicorp/terraform-plugin-docs v0.13.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 + github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect ) diff --git a/go.sum b/go.sum index d555d87..fb08a53 100755 --- a/go.sum +++ b/go.sum @@ -15,6 +15,7 @@ github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= @@ -48,8 +49,8 @@ github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -72,8 +73,8 @@ github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVH github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.4.9 h1:ESiK220/qE0aGxWdzKIvRH69iLiuN/PjoLTm69RoWtU= -github.com/hashicorp/go-plugin v1.4.9/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= +github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= +github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -88,18 +89,18 @@ github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= -github.com/hashicorp/terraform-plugin-framework v1.3.0 h1:WtP1CIaWAfbzME17xoUXvJcyh5Ewu9attdhbfWNnYLs= -github.com/hashicorp/terraform-plugin-framework v1.3.0/go.mod h1:A1WD3Ry7FhrThViUTbkx4ZDsMq9oaAv4U9oTI8bBzCU= +github.com/hashicorp/terraform-plugin-framework v1.3.5 h1:FJ6s3CVWVAxlhiF/jhy6hzs4AnPHiflsp9KgzTGl1wo= +github.com/hashicorp/terraform-plugin-framework v1.3.5/go.mod h1:2gGDpWiTI0irr9NSTLFAKlTi6KwGti3AoU19rFqU30o= github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0= github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE= -github.com/hashicorp/terraform-plugin-go v0.15.0 h1:1BJNSUFs09DS8h/XNyJNJaeusQuWc/T9V99ylU9Zwp0= -github.com/hashicorp/terraform-plugin-go v0.15.0/go.mod h1:tk9E3/Zx4RlF/9FdGAhwxHExqIHHldqiQGt20G6g+nQ= +github.com/hashicorp/terraform-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE= +github.com/hashicorp/terraform-plugin-go v0.18.0/go.mod h1:l7VK+2u5Kf2y+A+742GX0ouLut3gttudmvMgN0PA74Y= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-registry-address v0.2.0 h1:92LUg03NhfgZv44zpNTLBGIbiyTokQCDcdH5BhVHT3s= -github.com/hashicorp/terraform-registry-address v0.2.0/go.mod h1:478wuzJPzdmqT6OGbB/iH82EDcI8VFM4yujknh/1nIs= -github.com/hashicorp/terraform-svchost v0.0.1 h1:Zj6fR5wnpOHnJUmLyWozjMeDaVuE+cstMPj41/eKmSQ= -github.com/hashicorp/terraform-svchost v0.0.1/go.mod h1:ut8JaH0vumgdCfJaihdcZULqkAwHdQNwNH7taIDdsZM= +github.com/hashicorp/terraform-registry-address v0.2.1 h1:QuTf6oJ1+WSflJw6WYOHhLgwUiQ0FrROpHPYFtwTYWM= +github.com/hashicorp/terraform-registry-address v0.2.1/go.mod h1:BSE9fIFzp0qWsJUUyGquo4ldV9k2n+psif6NYkBRS3Y= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -189,8 +190,8 @@ github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= +github.com/zclconf/go-cty v1.13.1 h1:0a6bRwuiSHtAmqCqNOE+c2oHgepv0ctoxU4FUe43kwc= +github.com/zclconf/go-cty v1.13.1/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -199,16 +200,16 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -226,27 +227,27 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= +google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/provider/demo_resource.go b/internal/provider/demo_resource.go index 434e172..8c94afd 100755 --- a/internal/provider/demo_resource.go +++ b/internal/provider/demo_resource.go @@ -69,13 +69,13 @@ func (r *DemoResource) Schema(ctx context.Context, req resource.SchemaRequest, r PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, - Required: true, + Optional: true, Validators: []validator.String{ stringvalidator.OneOf( "read_write", ), }, - Description: `must be one of [read_write]`, + Description: `must be one of ["read_write"]`, }, "updated_at": schema.StringAttribute{ Computed: true, @@ -132,6 +132,9 @@ func (r *DemoResource) Create(ctx context.Context, req resource.CreateRequest, r res, err := r.client.Demo.CreateDemo(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -211,6 +214,9 @@ func (r *DemoResource) Delete(ctx context.Context, req resource.DeleteRequest, r res, err := r.client.Demo.DeleteDemo(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { diff --git a/internal/provider/demo_resource_sdk.go b/internal/provider/demo_resource_sdk.go index 020205b..fc06c8c 100755 --- a/internal/provider/demo_resource_sdk.go +++ b/internal/provider/demo_resource_sdk.go @@ -10,7 +10,12 @@ import ( func (r *DemoResourceModel) ToCreateSDKType() *shared.DemoParams { email := r.Email.ValueString() - permission := shared.DemoParamsPermission(r.Permission.ValueString()) + permission := new(shared.DemoParamsPermission) + if !r.Permission.IsUnknown() && !r.Permission.IsNull() { + *permission = shared.DemoParamsPermission(r.Permission.ValueString()) + } else { + permission = nil + } out := shared.DemoParams{ Email: email, Permission: permission, @@ -25,7 +30,7 @@ func (r *DemoResourceModel) ToDeleteSDKType() *shared.DemoParams { func (r *DemoResourceModel) RefreshFromCreateResponse(resp *shared.Demo) { if resp.CreatedAt != nil { - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339)) + r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) } else { r.CreatedAt = types.StringNull() } @@ -35,7 +40,7 @@ func (r *DemoResourceModel) RefreshFromCreateResponse(resp *shared.Demo) { r.ID = types.Int64Null() } if resp.UpdatedAt != nil { - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339)) + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) } else { r.UpdatedAt = types.StringNull() } diff --git a/internal/provider/grantkit_data_source.go b/internal/provider/grantkit_data_source.go new file mode 100755 index 0000000..9dccb41 --- /dev/null +++ b/internal/provider/grantkit_data_source.go @@ -0,0 +1,413 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package provider + +import ( + "abbey/v2/internal/sdk" + "abbey/v2/internal/sdk/pkg/models/operations" + "context" + "fmt" + + "abbey/v2/internal/validators" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &GrantKitDataSource{} +var _ datasource.DataSourceWithConfigure = &GrantKitDataSource{} + +func NewGrantKitDataSource() datasource.DataSource { + return &GrantKitDataSource{} +} + +// GrantKitDataSource is the data source implementation. +type GrantKitDataSource struct { + client *sdk.SDK +} + +// GrantKitDataSourceModel describes the data model. +type GrantKitDataSourceModel struct { + CreatedAt types.String `tfsdk:"created_at"` + CurrentVersionID types.String `tfsdk:"current_version_id"` + Description types.String `tfsdk:"description"` + Grants []Grant `tfsdk:"grants"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + Output Output `tfsdk:"output"` + Policies []Policy `tfsdk:"policies"` + Requests []Request `tfsdk:"requests"` + UpdatedAt types.String `tfsdk:"updated_at"` + Workflow *GrantWorkflow `tfsdk:"workflow"` +} + +// Metadata returns the data source type name. +func (r *GrantKitDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_grant_kit" +} + +// Schema defines the schema for the data source. +func (r *GrantKitDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "GrantKit DataSource", + + Attributes: map[string]schema.Attribute{ + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "current_version_id": schema.StringAttribute{ + Computed: true, + }, + "description": schema.StringAttribute{ + Computed: true, + }, + "grants": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "deleted": schema.BoolAttribute{ + Computed: true, + }, + "grant_kit_id": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_version_id": schema.StringAttribute{ + Computed: true, + }, + "id": schema.StringAttribute{ + Computed: true, + }, + "organization_id": schema.StringAttribute{ + Computed: true, + }, + "request_id": schema.StringAttribute{ + Computed: true, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "user_id": schema.StringAttribute{ + Computed: true, + }, + }, + }, + }, + "id": schema.StringAttribute{ + Required: true, + Description: `The ID of the grant kit or resource to retrieve.`, + }, + "name": schema.StringAttribute{ + Computed: true, + }, + "output": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "append": schema.StringAttribute{ + Computed: true, + }, + "location": schema.StringAttribute{ + Computed: true, + }, + "overwrite": schema.StringAttribute{ + Computed: true, + }, + }, + }, + "policies": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bundle": schema.StringAttribute{ + Computed: true, + }, + "query": schema.StringAttribute{ + Computed: true, + }, + }, + }, + }, + "requests": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "grant_id": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_id": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_name": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_version_id": schema.StringAttribute{ + Computed: true, + }, + "id": schema.StringAttribute{ + Computed: true, + }, + "pull_request": schema.StringAttribute{ + Computed: true, + }, + "reason": schema.StringAttribute{ + Computed: true, + }, + "reviews": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "grant": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "deleted": schema.BoolAttribute{ + Computed: true, + }, + "grant_kit_id": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_version_id": schema.StringAttribute{ + Computed: true, + }, + "id": schema.StringAttribute{ + Computed: true, + }, + "organization_id": schema.StringAttribute{ + Computed: true, + }, + "request_id": schema.StringAttribute{ + Computed: true, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "user_id": schema.StringAttribute{ + Computed: true, + }, + }, + }, + "grant_id": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_name": schema.StringAttribute{ + Computed: true, + }, + "grant_kit_version_id": schema.StringAttribute{ + Computed: true, + }, + "id": schema.StringAttribute{ + Computed: true, + }, + "pull_request": schema.StringAttribute{ + Computed: true, + }, + "reason": schema.StringAttribute{ + Computed: true, + }, + "request_id": schema.StringAttribute{ + Computed: true, + }, + "request_reason": schema.StringAttribute{ + Computed: true, + }, + "status": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf( + "Pending", + "Denied", + "Approved", + "Canceled", + ), + }, + Description: `must be one of ["Pending", "Denied", "Approved", "Canceled"]`, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "user_email": schema.StringAttribute{ + Computed: true, + }, + "user_id": schema.StringAttribute{ + Computed: true, + }, + }, + }, + }, + "status": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + stringvalidator.OneOf( + "Pending", + "Denied", + "Approved", + "Canceled", + ), + }, + Description: `must be one of ["Pending", "Denied", "Approved", "Canceled"]`, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "user_id": schema.StringAttribute{ + Computed: true, + }, + }, + }, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "workflow": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "steps": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "reviewers": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "all_of": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + }, + "one_of": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + }, + }, + }, + "skip_if": schema.ListNestedAttribute{ + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "bundle": schema.StringAttribute{ + Computed: true, + }, + "query": schema.StringAttribute{ + Computed: true, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } +} + +func (r *GrantKitDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*sdk.SDK) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected DataSource Configure Type", + fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *GrantKitDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data *GrantKitDataSourceModel + var item types.Object + + resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + })...) + + if resp.Diagnostics.HasError() { + return + } + + grantKitIDOrName := data.ID.ValueString() + request := operations.GetGrantKitByIDRequest{ + GrantKitIDOrName: grantKitIDOrName, + } + res, err := r.client.GrantKits.GetGrantKitByID(ctx, request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + if res.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + if res.GrantKit == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) + return + } + data.RefreshFromGetResponse(res.GrantKit) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/internal/provider/grantkit_data_source_sdk.go b/internal/provider/grantkit_data_source_sdk.go new file mode 100755 index 0000000..b5cf5b2 --- /dev/null +++ b/internal/provider/grantkit_data_source_sdk.go @@ -0,0 +1,161 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package provider + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "github.com/hashicorp/terraform-plugin-framework/types" + "time" +) + +func (r *GrantKitDataSourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { + r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) + r.CurrentVersionID = types.StringValue(resp.CurrentVersionID) + r.Description = types.StringValue(resp.Description) + r.Grants = nil + for _, grantsItem := range resp.Grants { + var grants1 Grant + grants1.CreatedAt = types.StringValue(grantsItem.CreatedAt.Format(time.RFC3339Nano)) + grants1.Deleted = types.BoolValue(grantsItem.Deleted) + grants1.GrantKitID = types.StringValue(grantsItem.GrantKitID) + grants1.GrantKitVersionID = types.StringValue(grantsItem.GrantKitVersionID) + grants1.ID = types.StringValue(grantsItem.ID) + grants1.OrganizationID = types.StringValue(grantsItem.OrganizationID) + grants1.RequestID = types.StringValue(grantsItem.RequestID) + grants1.UpdatedAt = types.StringValue(grantsItem.UpdatedAt.Format(time.RFC3339Nano)) + grants1.UserID = types.StringValue(grantsItem.UserID) + r.Grants = append(r.Grants, grants1) + } + r.ID = types.StringValue(resp.ID) + r.Name = types.StringValue(resp.Name) + if resp.Output.Append != nil { + r.Output.Append = types.StringValue(*resp.Output.Append) + } else { + r.Output.Append = types.StringNull() + } + r.Output.Location = types.StringValue(resp.Output.Location) + if resp.Output.Overwrite != nil { + r.Output.Overwrite = types.StringValue(*resp.Output.Overwrite) + } else { + r.Output.Overwrite = types.StringNull() + } + r.Policies = nil + for _, policiesItem := range resp.Policies { + var policies1 Policy + if policiesItem.Bundle != nil { + policies1.Bundle = types.StringValue(*policiesItem.Bundle) + } else { + policies1.Bundle = types.StringNull() + } + if policiesItem.Query != nil { + policies1.Query = types.StringValue(*policiesItem.Query) + } else { + policies1.Query = types.StringNull() + } + r.Policies = append(r.Policies, policies1) + } + r.Requests = nil + for _, requestsItem := range resp.Requests { + var requests1 Request + requests1.CreatedAt = types.StringValue(requestsItem.CreatedAt.Format(time.RFC3339Nano)) + requests1.GrantID = types.StringValue(requestsItem.GrantID) + requests1.GrantKitID = types.StringValue(requestsItem.GrantKitID) + if requestsItem.GrantKitName != nil { + requests1.GrantKitName = types.StringValue(*requestsItem.GrantKitName) + } else { + requests1.GrantKitName = types.StringNull() + } + requests1.GrantKitVersionID = types.StringValue(requestsItem.GrantKitVersionID) + requests1.ID = types.StringValue(requestsItem.ID) + requests1.PullRequest = types.StringValue(requestsItem.PullRequest) + requests1.Reason = types.StringValue(requestsItem.Reason) + requests1.Reviews = nil + for _, reviewsItem := range requestsItem.Reviews { + var reviews1 Review + reviews1.CreatedAt = types.StringValue(reviewsItem.CreatedAt.Format(time.RFC3339Nano)) + if reviews1.Grant == nil { + reviews1.Grant = &Grant{} + } + if reviewsItem.Grant == nil { + reviews1.Grant = nil + } else { + reviews1.Grant = &Grant{} + reviews1.Grant.CreatedAt = types.StringValue(reviewsItem.Grant.CreatedAt.Format(time.RFC3339Nano)) + reviews1.Grant.Deleted = types.BoolValue(reviewsItem.Grant.Deleted) + reviews1.Grant.GrantKitID = types.StringValue(reviewsItem.Grant.GrantKitID) + reviews1.Grant.GrantKitVersionID = types.StringValue(reviewsItem.Grant.GrantKitVersionID) + reviews1.Grant.ID = types.StringValue(reviewsItem.Grant.ID) + reviews1.Grant.OrganizationID = types.StringValue(reviewsItem.Grant.OrganizationID) + reviews1.Grant.RequestID = types.StringValue(reviewsItem.Grant.RequestID) + reviews1.Grant.UpdatedAt = types.StringValue(reviewsItem.Grant.UpdatedAt.Format(time.RFC3339Nano)) + reviews1.Grant.UserID = types.StringValue(reviewsItem.Grant.UserID) + } + reviews1.GrantID = types.StringValue(reviewsItem.GrantID) + reviews1.GrantKitName = types.StringValue(reviewsItem.GrantKitName) + reviews1.GrantKitVersionID = types.StringValue(reviewsItem.GrantKitVersionID) + reviews1.ID = types.StringValue(reviewsItem.ID) + reviews1.PullRequest = types.StringValue(reviewsItem.PullRequest) + reviews1.Reason = types.StringValue(reviewsItem.Reason) + reviews1.RequestID = types.StringValue(reviewsItem.RequestID) + reviews1.RequestReason = types.StringValue(reviewsItem.RequestReason) + reviews1.Status = types.StringValue(string(reviewsItem.Status)) + reviews1.UpdatedAt = types.StringValue(reviewsItem.UpdatedAt.Format(time.RFC3339Nano)) + if reviewsItem.UserEmail != nil { + reviews1.UserEmail = types.StringValue(*reviewsItem.UserEmail) + } else { + reviews1.UserEmail = types.StringNull() + } + reviews1.UserID = types.StringValue(reviewsItem.UserID) + requests1.Reviews = append(requests1.Reviews, reviews1) + } + requests1.Status = types.StringValue(string(requestsItem.Status)) + requests1.UpdatedAt = types.StringValue(requestsItem.UpdatedAt.Format(time.RFC3339Nano)) + requests1.UserID = types.StringValue(requestsItem.UserID) + r.Requests = append(r.Requests, requests1) + } + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) + if r.Workflow == nil { + r.Workflow = &GrantWorkflow{} + } + if resp.Workflow == nil { + r.Workflow = nil + } else { + r.Workflow = &GrantWorkflow{} + r.Workflow.Steps = nil + for _, stepsItem := range resp.Workflow.Steps { + var steps1 Step + if steps1.Reviewers == nil { + steps1.Reviewers = &Reviewers{} + } + if stepsItem.Reviewers == nil { + steps1.Reviewers = nil + } else { + steps1.Reviewers = &Reviewers{} + steps1.Reviewers.AllOf = nil + for _, v := range stepsItem.Reviewers.AllOf { + steps1.Reviewers.AllOf = append(steps1.Reviewers.AllOf, types.StringValue(v)) + } + steps1.Reviewers.OneOf = nil + for _, v := range stepsItem.Reviewers.OneOf { + steps1.Reviewers.OneOf = append(steps1.Reviewers.OneOf, types.StringValue(v)) + } + } + steps1.SkipIf = nil + for _, skipIfItem := range stepsItem.SkipIf { + var skipIf1 Policy + if skipIfItem.Bundle != nil { + skipIf1.Bundle = types.StringValue(*skipIfItem.Bundle) + } else { + skipIf1.Bundle = types.StringNull() + } + if skipIfItem.Query != nil { + skipIf1.Query = types.StringValue(*skipIfItem.Query) + } else { + skipIf1.Query = types.StringNull() + } + steps1.SkipIf = append(steps1.SkipIf, skipIf1) + } + r.Workflow.Steps = append(r.Workflow.Steps, steps1) + } + } +} diff --git a/internal/provider/grantkit_resource.go b/internal/provider/grantkit_resource.go index aa029af..a1a3d01 100755 --- a/internal/provider/grantkit_resource.go +++ b/internal/provider/grantkit_resource.go @@ -130,7 +130,6 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques }, }, "policies": schema.ListNestedAttribute{ - Computed: true, Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ @@ -223,7 +222,6 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques Computed: true, }, }, - Description: `Success`, }, "grant_id": schema.StringAttribute{ Computed: true, @@ -246,6 +244,9 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques "request_id": schema.StringAttribute{ Computed: true, }, + "request_reason": schema.StringAttribute{ + Computed: true, + }, "status": schema.StringAttribute{ Computed: true, Validators: []validator.String{ @@ -256,7 +257,7 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques "Canceled", ), }, - Description: `must be one of [Pending, Denied, Approved, Canceled]`, + Description: `must be one of ["Pending", "Denied", "Approved", "Canceled"]`, }, "updated_at": schema.StringAttribute{ Computed: true, @@ -283,7 +284,7 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques "Canceled", ), }, - Description: `must be one of [Pending, Denied, Approved, Canceled]`, + Description: `must be one of ["Pending", "Denied", "Approved", "Canceled"]`, }, "updated_at": schema.StringAttribute{ Computed: true, @@ -304,7 +305,6 @@ func (r *GrantKitResource) Schema(ctx context.Context, req resource.SchemaReques }, }, "workflow": schema.SingleNestedAttribute{ - Computed: true, Optional: true, Attributes: map[string]schema.Attribute{ "steps": schema.ListNestedAttribute{ @@ -395,6 +395,9 @@ func (r *GrantKitResource) Create(ctx context.Context, req resource.CreateReques res, err := r.client.GrantKits.CreateGrantKit(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -440,6 +443,9 @@ func (r *GrantKitResource) Read(ctx context.Context, req resource.ReadRequest, r res, err := r.client.GrantKits.GetGrantKitByID(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -476,6 +482,9 @@ func (r *GrantKitResource) Update(ctx context.Context, req resource.UpdateReques res, err := r.client.GrantKits.UpdateGrantKit(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -521,6 +530,9 @@ func (r *GrantKitResource) Delete(ctx context.Context, req resource.DeleteReques res, err := r.client.GrantKits.DeleteGrantKit(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { diff --git a/internal/provider/grantkit_resource_sdk.go b/internal/provider/grantkit_resource_sdk.go index 6e1428f..f6a5458 100755 --- a/internal/provider/grantkit_resource_sdk.go +++ b/internal/provider/grantkit_resource_sdk.go @@ -29,7 +29,7 @@ func (r *GrantKitResourceModel) ToCreateSDKType() *shared.GrantKitCreateParams { Location: location, Overwrite: overwrite, } - policies := make([]shared.Policy, 0) + var policies []shared.Policy = nil for _, policiesItem := range r.Policies { bundle := new(string) if !policiesItem.Bundle.IsUnknown() && !policiesItem.Bundle.IsNull() { @@ -50,15 +50,15 @@ func (r *GrantKitResourceModel) ToCreateSDKType() *shared.GrantKitCreateParams { } var workflow *shared.GrantWorkflow if r.Workflow != nil { - steps := make([]shared.Step, 0) + var steps []shared.Step = nil for _, stepsItem := range r.Workflow.Steps { var reviewers *shared.Reviewers if stepsItem.Reviewers != nil { - allOf := make([]string, 0) + var allOf []string = nil for _, allOfItem := range stepsItem.Reviewers.AllOf { allOf = append(allOf, allOfItem.ValueString()) } - oneOf := make([]string, 0) + var oneOf []string = nil for _, oneOfItem := range stepsItem.Reviewers.OneOf { oneOf = append(oneOf, oneOfItem.ValueString()) } @@ -67,7 +67,7 @@ func (r *GrantKitResourceModel) ToCreateSDKType() *shared.GrantKitCreateParams { OneOf: oneOf, } } - skipIf := make([]shared.Policy, 0) + var skipIf []shared.Policy = nil for _, skipIfItem := range stepsItem.SkipIf { bundle1 := new(string) if !skipIfItem.Bundle.IsUnknown() && !skipIfItem.Bundle.IsNull() { @@ -131,7 +131,7 @@ func (r *GrantKitResourceModel) ToUpdateSDKType() *shared.GrantKitUpdateParams { Location: location, Overwrite: overwrite, } - policies := make([]shared.Policy, 0) + var policies []shared.Policy = nil for _, policiesItem := range r.Policies { bundle := new(string) if !policiesItem.Bundle.IsUnknown() && !policiesItem.Bundle.IsNull() { @@ -152,15 +152,15 @@ func (r *GrantKitResourceModel) ToUpdateSDKType() *shared.GrantKitUpdateParams { } var workflow *shared.GrantWorkflow if r.Workflow != nil { - steps := make([]shared.Step, 0) + var steps []shared.Step = nil for _, stepsItem := range r.Workflow.Steps { var reviewers *shared.Reviewers if stepsItem.Reviewers != nil { - allOf := make([]string, 0) + var allOf []string = nil for _, allOfItem := range stepsItem.Reviewers.AllOf { allOf = append(allOf, allOfItem.ValueString()) } - oneOf := make([]string, 0) + var oneOf []string = nil for _, oneOfItem := range stepsItem.Reviewers.OneOf { oneOf = append(oneOf, oneOfItem.ValueString()) } @@ -169,7 +169,7 @@ func (r *GrantKitResourceModel) ToUpdateSDKType() *shared.GrantKitUpdateParams { OneOf: oneOf, } } - skipIf := make([]shared.Policy, 0) + var skipIf []shared.Policy = nil for _, skipIfItem := range stepsItem.SkipIf { bundle1 := new(string) if !skipIfItem.Bundle.IsUnknown() && !skipIfItem.Bundle.IsNull() { @@ -213,20 +213,20 @@ func (r *GrantKitResourceModel) ToDeleteSDKType() *shared.GrantKitCreateParams { } func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339)) + r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) r.CurrentVersionID = types.StringValue(resp.CurrentVersionID) r.Description = types.StringValue(resp.Description) r.Grants = nil for _, grantsItem := range resp.Grants { var grants1 Grant - grants1.CreatedAt = types.StringValue(grantsItem.CreatedAt.Format(time.RFC3339)) + grants1.CreatedAt = types.StringValue(grantsItem.CreatedAt.Format(time.RFC3339Nano)) grants1.Deleted = types.BoolValue(grantsItem.Deleted) grants1.GrantKitID = types.StringValue(grantsItem.GrantKitID) grants1.GrantKitVersionID = types.StringValue(grantsItem.GrantKitVersionID) grants1.ID = types.StringValue(grantsItem.ID) grants1.OrganizationID = types.StringValue(grantsItem.OrganizationID) grants1.RequestID = types.StringValue(grantsItem.RequestID) - grants1.UpdatedAt = types.StringValue(grantsItem.UpdatedAt.Format(time.RFC3339)) + grants1.UpdatedAt = types.StringValue(grantsItem.UpdatedAt.Format(time.RFC3339Nano)) grants1.UserID = types.StringValue(grantsItem.UserID) r.Grants = append(r.Grants, grants1) } @@ -261,7 +261,7 @@ func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { r.Requests = nil for _, requestsItem := range resp.Requests { var requests1 Request - requests1.CreatedAt = types.StringValue(requestsItem.CreatedAt.Format(time.RFC3339)) + requests1.CreatedAt = types.StringValue(requestsItem.CreatedAt.Format(time.RFC3339Nano)) requests1.GrantID = types.StringValue(requestsItem.GrantID) requests1.GrantKitID = types.StringValue(requestsItem.GrantKitID) if requestsItem.GrantKitName != nil { @@ -276,7 +276,7 @@ func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { requests1.Reviews = nil for _, reviewsItem := range requestsItem.Reviews { var reviews1 Review - reviews1.CreatedAt = types.StringValue(reviewsItem.CreatedAt.Format(time.RFC3339)) + reviews1.CreatedAt = types.StringValue(reviewsItem.CreatedAt.Format(time.RFC3339Nano)) if reviews1.Grant == nil { reviews1.Grant = &Grant{} } @@ -284,14 +284,14 @@ func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { reviews1.Grant = nil } else { reviews1.Grant = &Grant{} - reviews1.Grant.CreatedAt = types.StringValue(reviewsItem.Grant.CreatedAt.Format(time.RFC3339)) + reviews1.Grant.CreatedAt = types.StringValue(reviewsItem.Grant.CreatedAt.Format(time.RFC3339Nano)) reviews1.Grant.Deleted = types.BoolValue(reviewsItem.Grant.Deleted) reviews1.Grant.GrantKitID = types.StringValue(reviewsItem.Grant.GrantKitID) reviews1.Grant.GrantKitVersionID = types.StringValue(reviewsItem.Grant.GrantKitVersionID) reviews1.Grant.ID = types.StringValue(reviewsItem.Grant.ID) reviews1.Grant.OrganizationID = types.StringValue(reviewsItem.Grant.OrganizationID) reviews1.Grant.RequestID = types.StringValue(reviewsItem.Grant.RequestID) - reviews1.Grant.UpdatedAt = types.StringValue(reviewsItem.Grant.UpdatedAt.Format(time.RFC3339)) + reviews1.Grant.UpdatedAt = types.StringValue(reviewsItem.Grant.UpdatedAt.Format(time.RFC3339Nano)) reviews1.Grant.UserID = types.StringValue(reviewsItem.Grant.UserID) } reviews1.GrantID = types.StringValue(reviewsItem.GrantID) @@ -301,8 +301,9 @@ func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { reviews1.PullRequest = types.StringValue(reviewsItem.PullRequest) reviews1.Reason = types.StringValue(reviewsItem.Reason) reviews1.RequestID = types.StringValue(reviewsItem.RequestID) + reviews1.RequestReason = types.StringValue(reviewsItem.RequestReason) reviews1.Status = types.StringValue(string(reviewsItem.Status)) - reviews1.UpdatedAt = types.StringValue(reviewsItem.UpdatedAt.Format(time.RFC3339)) + reviews1.UpdatedAt = types.StringValue(reviewsItem.UpdatedAt.Format(time.RFC3339Nano)) if reviewsItem.UserEmail != nil { reviews1.UserEmail = types.StringValue(*reviewsItem.UserEmail) } else { @@ -312,11 +313,11 @@ func (r *GrantKitResourceModel) RefreshFromGetResponse(resp *shared.GrantKit) { requests1.Reviews = append(requests1.Reviews, reviews1) } requests1.Status = types.StringValue(string(requestsItem.Status)) - requests1.UpdatedAt = types.StringValue(requestsItem.UpdatedAt.Format(time.RFC3339)) + requests1.UpdatedAt = types.StringValue(requestsItem.UpdatedAt.Format(time.RFC3339Nano)) requests1.UserID = types.StringValue(requestsItem.UserID) r.Requests = append(r.Requests, requests1) } - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339)) + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) if r.Workflow == nil { r.Workflow = &GrantWorkflow{} } diff --git a/internal/provider/identity_data_source.go b/internal/provider/identity_data_source.go new file mode 100755 index 0000000..14a5501 --- /dev/null +++ b/internal/provider/identity_data_source.go @@ -0,0 +1,149 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package provider + +import ( + "abbey/v2/internal/sdk" + "abbey/v2/internal/sdk/pkg/models/operations" + "context" + "fmt" + + "abbey/v2/internal/validators" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &IdentityDataSource{} +var _ datasource.DataSourceWithConfigure = &IdentityDataSource{} + +func NewIdentityDataSource() datasource.DataSource { + return &IdentityDataSource{} +} + +// IdentityDataSource is the data source implementation. +type IdentityDataSource struct { + client *sdk.SDK +} + +// IdentityDataSourceModel describes the data model. +type IdentityDataSourceModel struct { + AbbeyAccount types.String `tfsdk:"abbey_account"` + CreatedAt types.String `tfsdk:"created_at"` + ID types.String `tfsdk:"id"` + Metadata types.String `tfsdk:"metadata"` + Source types.String `tfsdk:"source"` + UpdatedAt types.String `tfsdk:"updated_at"` +} + +// Metadata returns the data source type name. +func (r *IdentityDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_identity" +} + +// Schema defines the schema for the data source. +func (r *IdentityDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Identity DataSource", + + Attributes: map[string]schema.Attribute{ + "abbey_account": schema.StringAttribute{ + Computed: true, + }, + "created_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + "id": schema.StringAttribute{ + Required: true, + Description: `The ID of the identity to retrieve`, + }, + "metadata": schema.StringAttribute{ + Computed: true, + Description: `Json encoded string. See documentation for details.`, + }, + "source": schema.StringAttribute{ + Computed: true, + }, + "updated_at": schema.StringAttribute{ + Computed: true, + Validators: []validator.String{ + validators.IsRFC3339(), + }, + }, + }, + } +} + +func (r *IdentityDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*sdk.SDK) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected DataSource Configure Type", + fmt.Sprintf("Expected *sdk.SDK, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client +} + +func (r *IdentityDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data *IdentityDataSourceModel + var item types.Object + + resp.Diagnostics.Append(req.Config.Get(ctx, &item)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + UnhandledNullAsEmpty: true, + UnhandledUnknownAsEmpty: true, + })...) + + if resp.Diagnostics.HasError() { + return + } + + identityID := data.ID.ValueString() + request := operations.GetIdentityRequest{ + IdentityID: identityID, + } + res, err := r.client.Identities.GetIdentity(ctx, request) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } + return + } + if res == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res)) + return + } + if res.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) + return + } + if res.Identity == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) + return + } + data.RefreshFromGetResponse(res.Identity) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/internal/provider/identity_data_source_sdk.go b/internal/provider/identity_data_source_sdk.go new file mode 100755 index 0000000..ed775b9 --- /dev/null +++ b/internal/provider/identity_data_source_sdk.go @@ -0,0 +1,18 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package provider + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "github.com/hashicorp/terraform-plugin-framework/types" + "time" +) + +func (r *IdentityDataSourceModel) RefreshFromGetResponse(resp *shared.Identity) { + r.AbbeyAccount = types.StringValue(resp.AbbeyAccount) + r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) + r.ID = types.StringValue(resp.ID) + r.Metadata = types.StringValue(resp.Metadata) + r.Source = types.StringValue(resp.Source) + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) +} diff --git a/internal/provider/identity_resource.go b/internal/provider/identity_resource.go index 65ca10f..7f9b87d 100755 --- a/internal/provider/identity_resource.go +++ b/internal/provider/identity_resource.go @@ -120,6 +120,9 @@ func (r *IdentityResource) Create(ctx context.Context, req resource.CreateReques res, err := r.client.Identities.CreateIdentity(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -165,6 +168,9 @@ func (r *IdentityResource) Read(ctx context.Context, req resource.ReadRequest, r res, err := r.client.Identities.GetIdentity(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -201,6 +207,9 @@ func (r *IdentityResource) Update(ctx context.Context, req resource.UpdateReques res, err := r.client.Identities.UpdateIdentity(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { @@ -246,6 +255,9 @@ func (r *IdentityResource) Delete(ctx context.Context, req resource.DeleteReques res, err := r.client.Identities.DeleteIdentity(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res != nil && res.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res.RawResponse)) + } return } if res == nil { diff --git a/internal/provider/identity_resource_sdk.go b/internal/provider/identity_resource_sdk.go index 46b40fe..a8bc2a6 100755 --- a/internal/provider/identity_resource_sdk.go +++ b/internal/provider/identity_resource_sdk.go @@ -37,11 +37,11 @@ func (r *IdentityResourceModel) ToDeleteSDKType() *shared.IdentityParams { func (r *IdentityResourceModel) RefreshFromGetResponse(resp *shared.Identity) { r.AbbeyAccount = types.StringValue(resp.AbbeyAccount) - r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339)) + r.CreatedAt = types.StringValue(resp.CreatedAt.Format(time.RFC3339Nano)) r.ID = types.StringValue(resp.ID) r.Metadata = types.StringValue(resp.Metadata) r.Source = types.StringValue(resp.Source) - r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339)) + r.UpdatedAt = types.StringValue(resp.UpdatedAt.Format(time.RFC3339Nano)) } func (r *IdentityResourceModel) RefreshFromCreateResponse(resp *shared.Identity) { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 1d9fd5f..c9a79ee 100755 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -92,7 +92,10 @@ func (p *AbbeyProvider) Resources(ctx context.Context) []func() resource.Resourc } func (p *AbbeyProvider) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{} + return []func() datasource.DataSource{ + NewGrantKitDataSource, + NewIdentityDataSource, + } } func New(version string) func() provider.Provider { diff --git a/internal/provider/type_review.go b/internal/provider/type_review.go index 6d9c8b3..ba1c7f3 100755 --- a/internal/provider/type_review.go +++ b/internal/provider/type_review.go @@ -14,6 +14,7 @@ type Review struct { PullRequest types.String `tfsdk:"pull_request"` Reason types.String `tfsdk:"reason"` RequestID types.String `tfsdk:"request_id"` + RequestReason types.String `tfsdk:"request_reason"` Status types.String `tfsdk:"status"` UpdatedAt types.String `tfsdk:"updated_at"` UserEmail types.String `tfsdk:"user_email"` diff --git a/internal/provider/utils.go b/internal/provider/utils.go index b44ef79..9da2fe4 100755 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -18,9 +18,12 @@ import ( ) func debugResponse(response *http.Response) string { - dumpReq, err := httputil.DumpRequest(response.Request, false) + dumpReq, err := httputil.DumpRequest(response.Request, true) if err != nil { - return err.Error() + dumpReq, err = httputil.DumpRequest(response.Request, false) + if err != nil { + return err.Error() + } } dumpRes, err := httputil.DumpResponse(response, true) if err != nil { diff --git a/internal/sdk/analytics.go b/internal/sdk/analytics.go new file mode 100755 index 0000000..b2c98ca --- /dev/null +++ b/internal/sdk/analytics.go @@ -0,0 +1,233 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +// analytics - Analytics endpoints for use in the console +type analytics struct { + sdkConfiguration sdkConfiguration +} + +func newAnalytics(sdkConfig sdkConfiguration) *analytics { + return &analytics{ + sdkConfiguration: sdkConfig, + } +} + +// CountApprovalsByUser - outputs the number of access requests approvals and denials for a user +// Returns the number of access requests approvals and denials for a user +func (s *analytics) CountApprovalsByUser(ctx context.Context) (*operations.CountApprovalsByUserResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/analytics/approval-counts-by-user" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CountApprovalsByUserResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.UserApprovalAnalytics + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.UserApprovalAnalytics = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// CountGrantKitsForOrganization - outputs the number of grant kits a user's organizations +// Returns the number of grant kits owned by all the organizations a user is in +func (s *analytics) CountGrantKitsForOrganization(ctx context.Context) (*operations.CountGrantKitsForOrganizationResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/analytics/num-grant-kits" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CountGrantKitsForOrganizationResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.OrganizationGrantKitCounts + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.OrganizationGrantKitCounts = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// CountRequestsByResourceForOrg - outputs the number of resource requests for each resource owned by a user's org +// Returns the number of resource requests each resource in a user's org has +func (s *analytics) CountRequestsByResourceForOrg(ctx context.Context) (*operations.CountRequestsByResourceForOrgResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/analytics/resource-request-counts-for-org" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CountRequestsByResourceForOrgResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.ResourceRequestCounts + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.ResourceRequestCounts = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/apikeys.go b/internal/sdk/apikeys.go index 4ba6a2a..2dace89 100755 --- a/internal/sdk/apikeys.go +++ b/internal/sdk/apikeys.go @@ -41,12 +41,15 @@ func (s *apiKeys) CreateAPIKey(ctx context.Context, request shared.APIKeysCreate return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -64,6 +67,7 @@ func (s *apiKeys) CreateAPIKey(ctx context.Context, request shared.APIKeysCreate if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -80,7 +84,7 @@ func (s *apiKeys) CreateAPIKey(ctx context.Context, request shared.APIKeysCreate case utils.MatchContentType(contentType, `application/json`): var out *shared.APIKey if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.APIKey = out @@ -98,7 +102,7 @@ func (s *apiKeys) CreateAPIKey(ctx context.Context, request shared.APIKeysCreate case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -119,7 +123,7 @@ func (s *apiKeys) GetAPIKeys(ctx context.Context) (*operations.GetAPIKeysRespons return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -151,7 +155,7 @@ func (s *apiKeys) GetAPIKeys(ctx context.Context) (*operations.GetAPIKeysRespons case utils.MatchContentType(contentType, `application/json`): var out *shared.APIKeys if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.APIKeys = out @@ -165,7 +169,7 @@ func (s *apiKeys) GetAPIKeys(ctx context.Context) (*operations.GetAPIKeysRespons case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -189,7 +193,7 @@ func (s *apiKeys) DeleteAPIKey(ctx context.Context, request operations.DeleteAPI return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -228,7 +232,7 @@ func (s *apiKeys) DeleteAPIKey(ctx context.Context, request operations.DeleteAPI case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/connections.go b/internal/sdk/connections.go index 20d81e6..4c19672 100755 --- a/internal/sdk/connections.go +++ b/internal/sdk/connections.go @@ -43,12 +43,15 @@ func (s *connections) CreateConnection(ctx context.Context, request shared.Conne return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -66,6 +69,7 @@ func (s *connections) CreateConnection(ctx context.Context, request shared.Conne if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -82,7 +86,7 @@ func (s *connections) CreateConnection(ctx context.Context, request shared.Conne case utils.MatchContentType(contentType, `application/json`): var out *shared.Connection if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Connection = out @@ -100,7 +104,159 @@ func (s *connections) CreateConnection(ctx context.Context, request shared.Conne case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// CreateGHEApp - Registers new GHE App +// Registers a new instance of app for GHE Server +func (s *connections) CreateGHEApp(ctx context.Context, request shared.GithubEnterpriseAppParams) (*operations.CreateGHEAppResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/connections/ghe-app" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CreateGHEAppResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.GithubEnterpriseApp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.GithubEnterpriseApp = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// DeleteGHEApp - Update a GHE App +// Updates the specified GHE App. +func (s *connections) DeleteGHEApp(ctx context.Context, request operations.DeleteGHEAppRequest) (*operations.DeleteGHEAppResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/connections/ghe-app/{app_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.DeleteGHEAppResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err } res.Error = out @@ -124,7 +280,7 @@ func (s *connections) GetConnection(ctx context.Context, request operations.GetC return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -156,7 +312,7 @@ func (s *connections) GetConnection(ctx context.Context, request operations.GetC case utils.MatchContentType(contentType, `application/json`): var out *shared.Connection if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Connection = out @@ -172,7 +328,79 @@ func (s *connections) GetConnection(ctx context.Context, request operations.GetC case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// GetGHEApp - Retrieve a GHE App by ID +// Returns the details of a GHE App. +func (s *connections) GetGHEApp(ctx context.Context, request operations.GetGHEAppRequest) (*operations.GetGHEAppResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/connections/ghe-app/{app_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.GetGHEAppResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.GithubEnterpriseApp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.GithubEnterpriseApp = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err } res.Error = out @@ -194,7 +422,7 @@ func (s *connections) ListConnections(ctx context.Context) (*operations.ListConn return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -226,7 +454,7 @@ func (s *connections) ListConnections(ctx context.Context) (*operations.ListConn case utils.MatchContentType(contentType, `application/json`): var out *shared.ConnectionListing if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.ConnectionListing = out @@ -240,7 +468,76 @@ func (s *connections) ListConnections(ctx context.Context) (*operations.ListConn case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// ListGHEApp - Lists GHE Apps +// Returns the details of a GHE apps registered with this org +// +// Apps are sorted by Application Ids, descending. +func (s *connections) ListGHEApp(ctx context.Context) (*operations.ListGHEAppResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/connections/ghe-app" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.ListGHEAppResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out []shared.GithubEnterpriseApp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.GithubEnterpriseApps = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err } res.Error = out @@ -267,12 +564,15 @@ func (s *connections) UpdateConnection(ctx context.Context, request operations.U return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -290,6 +590,7 @@ func (s *connections) UpdateConnection(ctx context.Context, request operations.U if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -306,7 +607,7 @@ func (s *connections) UpdateConnection(ctx context.Context, request operations.U case utils.MatchContentType(contentType, `application/json`): var out *shared.Connection if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Connection = out @@ -326,7 +627,97 @@ func (s *connections) UpdateConnection(ctx context.Context, request operations.U case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// UpdateGHEApp - Update a GHE App +// Updates the specified GHE App. +func (s *connections) UpdateGHEApp(ctx context.Context, request operations.UpdateGHEAppRequest) (*operations.UpdateGHEAppResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/connections/ghe-app/{app_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "GithubEnterpriseAppParams", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.UpdateGHEAppResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.GithubEnterpriseApp + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.GithubEnterpriseApp = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err } res.Error = out diff --git a/internal/sdk/connectionspecs.go b/internal/sdk/connectionspecs.go index 6c4a3bf..e0d426e 100755 --- a/internal/sdk/connectionspecs.go +++ b/internal/sdk/connectionspecs.go @@ -40,7 +40,7 @@ func (s *connectionSpecs) ListConnectionSpecs(ctx context.Context) (*operations. return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -72,7 +72,7 @@ func (s *connectionSpecs) ListConnectionSpecs(ctx context.Context) (*operations. case utils.MatchContentType(contentType, `application/json`): var out *shared.ConnectionSpecListing if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.ConnectionSpecListing = out @@ -86,7 +86,7 @@ func (s *connectionSpecs) ListConnectionSpecs(ctx context.Context) (*operations. case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/demo.go b/internal/sdk/demo.go index b0d148e..def1004 100755 --- a/internal/sdk/demo.go +++ b/internal/sdk/demo.go @@ -40,12 +40,15 @@ func (s *demo) CreateDemo(ctx context.Context, request shared.DemoParams) (*oper return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -63,6 +66,7 @@ func (s *demo) CreateDemo(ctx context.Context, request shared.DemoParams) (*oper if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -79,7 +83,7 @@ func (s *demo) CreateDemo(ctx context.Context, request shared.DemoParams) (*oper case utils.MatchContentType(contentType, `application/json`): var out *shared.Demo if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Demo = out @@ -95,7 +99,7 @@ func (s *demo) CreateDemo(ctx context.Context, request shared.DemoParams) (*oper case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -119,12 +123,15 @@ func (s *demo) DeleteDemo(ctx context.Context, request shared.DemoParams) (*oper return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "DELETE", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "DELETE", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -142,6 +149,7 @@ func (s *demo) DeleteDemo(ctx context.Context, request shared.DemoParams) (*oper if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -158,7 +166,7 @@ func (s *demo) DeleteDemo(ctx context.Context, request shared.DemoParams) (*oper case utils.MatchContentType(contentType, `application/json`): var out *shared.Demo if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Demo = out @@ -174,7 +182,7 @@ func (s *demo) DeleteDemo(ctx context.Context, request shared.DemoParams) (*oper case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -186,26 +194,20 @@ func (s *demo) DeleteDemo(ctx context.Context, request shared.DemoParams) (*oper // GetDemo - Get Demo // Get the demo response -func (s *demo) GetDemo(ctx context.Context, request shared.DemoParams) (*operations.GetDemoResponse, error) { +func (s *demo) GetDemo(ctx context.Context, request operations.GetDemoRequest) (*operations.GetDemoResponse, error) { baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) url := strings.TrimSuffix(baseURL, "/") + "/demo" - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") - if err != nil { - return nil, fmt.Errorf("error serializing request body: %w", err) - } - if bodyReader == nil { - return nil, fmt.Errorf("request body is required") - } - - req, err := http.NewRequestWithContext(ctx, "GET", url, bodyReader) + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) - req.Header.Set("Content-Type", reqContentType) + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } client := s.sdkConfiguration.SecurityClient @@ -237,7 +239,7 @@ func (s *demo) GetDemo(ctx context.Context, request shared.DemoParams) (*operati case utils.MatchContentType(contentType, `application/json`): var out *shared.Demo if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Demo = out @@ -253,7 +255,7 @@ func (s *demo) GetDemo(ctx context.Context, request shared.DemoParams) (*operati case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/directorysync.go b/internal/sdk/directorysync.go new file mode 100755 index 0000000..9af9783 --- /dev/null +++ b/internal/sdk/directorysync.go @@ -0,0 +1,389 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +type directorySync struct { + sdkConfiguration sdkConfiguration +} + +func newDirectorySync(sdkConfig sdkConfiguration) *directorySync { + return &directorySync{ + sdkConfiguration: sdkConfig, + } +} + +// CreateDirectory - create a directory sync org +// Creates a directory if the current org does not have one +func (s *directorySync) CreateDirectory(ctx context.Context, request shared.DirectorySyncParams) (*operations.CreateDirectoryResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/directory-sync" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CreateDirectoryResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.DirectorySync + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.DirectorySync = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// DeleteDirectory - delete a directory sync org +// Deletes a directory if the current org if one exists +func (s *directorySync) DeleteDirectory(ctx context.Context) (*operations.DeleteDirectoryResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/directory-sync" + + req, err := http.NewRequestWithContext(ctx, "DELETE", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.DeleteDirectoryResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// GetDirectory - gets a directory sync org +// Gets a directory if the current org if one exists +func (s *directorySync) GetDirectory(ctx context.Context) (*operations.GetDirectoryResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/directory-sync" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.GetDirectoryResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.DirectorySync + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.DirectorySync = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// GetPortalLink - gets a directory sync admin portal link +// Gets the admin portal link for a directory. This will be valid for 5 minutes. +func (s *directorySync) GetPortalLink(ctx context.Context) (*operations.GetPortalLinkResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/directory-sync/admin-portal" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.GetPortalLinkResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.DirectorySyncAdminPortal + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.DirectorySyncAdminPortal = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// UpdateDirectory - update a directory sync org +// Updates a directory if the current org does not have one +func (s *directorySync) UpdateDirectory(ctx context.Context, request shared.DirectorySyncParams) (*operations.UpdateDirectoryResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/directory-sync" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.UpdateDirectoryResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.DirectorySync + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.DirectorySync = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/grantkits.go b/internal/sdk/grantkits.go index a46278b..70b1cfd 100755 --- a/internal/sdk/grantkits.go +++ b/internal/sdk/grantkits.go @@ -46,12 +46,15 @@ func (s *grantKits) CreateGrantKit(ctx context.Context, request shared.GrantKitC return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -69,6 +72,7 @@ func (s *grantKits) CreateGrantKit(ctx context.Context, request shared.GrantKitC if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -85,7 +89,7 @@ func (s *grantKits) CreateGrantKit(ctx context.Context, request shared.GrantKitC case utils.MatchContentType(contentType, `application/json`): var out *shared.GrantKit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKit = out @@ -103,7 +107,7 @@ func (s *grantKits) CreateGrantKit(ctx context.Context, request shared.GrantKitC case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -126,7 +130,7 @@ func (s *grantKits) ListGrantKits(ctx context.Context) (*operations.ListGrantKit return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -158,7 +162,7 @@ func (s *grantKits) ListGrantKits(ctx context.Context) (*operations.ListGrantKit case utils.MatchContentType(contentType, `application/json`): var out []shared.GrantKit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKits = out @@ -172,7 +176,7 @@ func (s *grantKits) ListGrantKits(ctx context.Context) (*operations.ListGrantKit case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -196,7 +200,7 @@ func (s *grantKits) DeleteGrantKit(ctx context.Context, request operations.Delet return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -228,7 +232,7 @@ func (s *grantKits) DeleteGrantKit(ctx context.Context, request operations.Delet case utils.MatchContentType(contentType, `application/json`): var out *shared.GrantKit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKit = out @@ -244,7 +248,7 @@ func (s *grantKits) DeleteGrantKit(ctx context.Context, request operations.Delet case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -268,7 +272,7 @@ func (s *grantKits) GetGrantKitByID(ctx context.Context, request operations.GetG return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -300,7 +304,7 @@ func (s *grantKits) GetGrantKitByID(ctx context.Context, request operations.GetG case utils.MatchContentType(contentType, `application/json`): var out *shared.GrantKit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKit = out @@ -316,7 +320,7 @@ func (s *grantKits) GetGrantKitByID(ctx context.Context, request operations.GetG case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -342,7 +346,7 @@ func (s *grantKits) ListGrantKitVersionsByID(ctx context.Context, request operat return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -374,7 +378,7 @@ func (s *grantKits) ListGrantKitVersionsByID(ctx context.Context, request operat case utils.MatchContentType(contentType, `application/json`): var out []shared.GrantKitVersion if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKitVersions = out @@ -390,7 +394,7 @@ func (s *grantKits) ListGrantKitVersionsByID(ctx context.Context, request operat case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -417,12 +421,15 @@ func (s *grantKits) UpdateGrantKit(ctx context.Context, request operations.Updat return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -440,6 +447,7 @@ func (s *grantKits) UpdateGrantKit(ctx context.Context, request operations.Updat if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -456,7 +464,7 @@ func (s *grantKits) UpdateGrantKit(ctx context.Context, request operations.Updat case utils.MatchContentType(contentType, `application/json`): var out *shared.GrantKit if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.GrantKit = out @@ -476,7 +484,7 @@ func (s *grantKits) UpdateGrantKit(ctx context.Context, request operations.Updat case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/grants.go b/internal/sdk/grants.go index cb9f056..7149458 100755 --- a/internal/sdk/grants.go +++ b/internal/sdk/grants.go @@ -44,7 +44,7 @@ func (s *grants) ListGrants(ctx context.Context) (*operations.ListGrantsResponse return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -76,7 +76,7 @@ func (s *grants) ListGrants(ctx context.Context) (*operations.ListGrantsResponse case utils.MatchContentType(contentType, `application/json`): var out []shared.Grant if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Grants = out @@ -90,7 +90,7 @@ func (s *grants) ListGrants(ctx context.Context) (*operations.ListGrantsResponse case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -114,7 +114,7 @@ func (s *grants) GetGrantByID(ctx context.Context, request operations.GetGrantBy return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -146,7 +146,7 @@ func (s *grants) GetGrantByID(ctx context.Context, request operations.GetGrantBy case utils.MatchContentType(contentType, `application/json`): var out *shared.Grant if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Grant = out @@ -162,7 +162,7 @@ func (s *grants) GetGrantByID(ctx context.Context, request operations.GetGrantBy case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -186,7 +186,7 @@ func (s *grants) RevokeGrant(ctx context.Context, request operations.RevokeGrant return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -218,7 +218,7 @@ func (s *grants) RevokeGrant(ctx context.Context, request operations.RevokeGrant case utils.MatchContentType(contentType, `application/json`): var out *shared.Grant if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Grant = out @@ -238,7 +238,7 @@ func (s *grants) RevokeGrant(ctx context.Context, request operations.RevokeGrant case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/identities.go b/internal/sdk/identities.go index de94b2a..6602ed8 100755 --- a/internal/sdk/identities.go +++ b/internal/sdk/identities.go @@ -44,12 +44,15 @@ func (s *identities) CreateIdentity(ctx context.Context, request shared.Identity return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -67,6 +70,7 @@ func (s *identities) CreateIdentity(ctx context.Context, request shared.Identity if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -83,7 +87,7 @@ func (s *identities) CreateIdentity(ctx context.Context, request shared.Identity case utils.MatchContentType(contentType, `application/json`): var out *shared.Identity if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Identity = out @@ -101,7 +105,7 @@ func (s *identities) CreateIdentity(ctx context.Context, request shared.Identity case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -125,7 +129,7 @@ func (s *identities) DeleteIdentity(ctx context.Context, request operations.Dele return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -153,6 +157,8 @@ func (s *identities) DeleteIdentity(ctx context.Context, request operations.Dele } switch { case httpRes.StatusCode == 200: + fallthrough + case httpRes.StatusCode == 204: case httpRes.StatusCode == 401: fallthrough case httpRes.StatusCode == 404: @@ -164,7 +170,7 @@ func (s *identities) DeleteIdentity(ctx context.Context, request operations.Dele case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -188,7 +194,7 @@ func (s *identities) GetIdentity(ctx context.Context, request operations.GetIden return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -220,7 +226,7 @@ func (s *identities) GetIdentity(ctx context.Context, request operations.GetIden case utils.MatchContentType(contentType, `application/json`): var out *shared.Identity if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Identity = out @@ -236,7 +242,76 @@ func (s *identities) GetIdentity(ctx context.Context, request operations.GetIden case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// ListEnrichedIdentities - List all Identities with enriched metadata +// Returns all Identities with enriched metadata in the org +func (s *identities) ListEnrichedIdentities(ctx context.Context) (*operations.ListEnrichedIdentitiesResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/identities" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.ListEnrichedIdentitiesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out []shared.Identity + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Identities = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err } res.Error = out @@ -263,12 +338,15 @@ func (s *identities) UpdateIdentity(ctx context.Context, request operations.Upda return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -286,6 +364,7 @@ func (s *identities) UpdateIdentity(ctx context.Context, request operations.Upda if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -302,7 +381,7 @@ func (s *identities) UpdateIdentity(ctx context.Context, request operations.Upda case utils.MatchContentType(contentType, `application/json`): var out *shared.Identity if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Identity = out @@ -318,7 +397,7 @@ func (s *identities) UpdateIdentity(ctx context.Context, request operations.Upda case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/oauth.go b/internal/sdk/oauth.go new file mode 100755 index 0000000..1d4d6a2 --- /dev/null +++ b/internal/sdk/oauth.go @@ -0,0 +1,101 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +// oauth - Abbey OAuth +// https://docs.abbey.io +type oauth struct { + sdkConfiguration sdkConfiguration +} + +func newOauth(sdkConfig sdkConfiguration) *oauth { + return &oauth{ + sdkConfiguration: sdkConfig, + } +} + +// CreateOAuth - Create access token via OAuth +// Create and store a new OAuth token +func (s *oauth) CreateOAuth(ctx context.Context, request shared.OAuthCreateParams) (*operations.CreateOAuthResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/oauth" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CreateOAuthResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 201: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/oauths.go b/internal/sdk/oauths.go new file mode 100755 index 0000000..18b0655 --- /dev/null +++ b/internal/sdk/oauths.go @@ -0,0 +1,92 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +type oauths struct { + sdkConfiguration sdkConfiguration +} + +func newOauths(sdkConfig sdkConfiguration) *oauths { + return &oauths{ + sdkConfiguration: sdkConfig, + } +} + +// ListOauths - List OAuths +// Returns a list of oauth token IDs. +func (s *oauths) ListOauths(ctx context.Context) (*operations.ListOauthsResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/oauths" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.ListOauthsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.OauthListing + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.OauthListing = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/pkg/models/operations/approvereview.go b/internal/sdk/pkg/models/operations/approvereview.go index 71f9e64..b35c013 100755 --- a/internal/sdk/pkg/models/operations/approvereview.go +++ b/internal/sdk/pkg/models/operations/approvereview.go @@ -14,11 +14,14 @@ type ApproveReviewRequest struct { } type ApproveReviewResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Success - Review *shared.Review - StatusCode int + Review *shared.Review + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/cancelrequestbyid.go b/internal/sdk/pkg/models/operations/cancelrequestbyid.go index 62e1020..4430e6f 100755 --- a/internal/sdk/pkg/models/operations/cancelrequestbyid.go +++ b/internal/sdk/pkg/models/operations/cancelrequestbyid.go @@ -14,11 +14,14 @@ type CancelRequestByIDRequest struct { } type CancelRequestByIDResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Success - Request *shared.Request - StatusCode int + Request *shared.Request + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/countapprovalsbyuser.go b/internal/sdk/pkg/models/operations/countapprovalsbyuser.go new file mode 100755 index 0000000..d7c3b43 --- /dev/null +++ b/internal/sdk/pkg/models/operations/countapprovalsbyuser.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CountApprovalsByUserResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // Success + UserApprovalAnalytics *shared.UserApprovalAnalytics +} diff --git a/internal/sdk/pkg/models/operations/countgrantkitsfororganization.go b/internal/sdk/pkg/models/operations/countgrantkitsfororganization.go new file mode 100755 index 0000000..292d210 --- /dev/null +++ b/internal/sdk/pkg/models/operations/countgrantkitsfororganization.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CountGrantKitsForOrganizationResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Success + OrganizationGrantKitCounts *shared.OrganizationGrantKitCounts + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/countrequestsbyresourcefororg.go b/internal/sdk/pkg/models/operations/countrequestsbyresourcefororg.go new file mode 100755 index 0000000..b784851 --- /dev/null +++ b/internal/sdk/pkg/models/operations/countrequestsbyresourcefororg.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CountRequestsByResourceForOrgResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Success + ResourceRequestCounts *shared.ResourceRequestCounts + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/createapikey.go b/internal/sdk/pkg/models/operations/createapikey.go index 381eeba..880f31c 100755 --- a/internal/sdk/pkg/models/operations/createapikey.go +++ b/internal/sdk/pkg/models/operations/createapikey.go @@ -9,10 +9,13 @@ import ( type CreateAPIKeyResponse struct { // Created - APIKey *shared.APIKey + APIKey *shared.APIKey + // HTTP response content type for this operation ContentType string // Request Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createconnection.go b/internal/sdk/pkg/models/operations/createconnection.go index bc43004..6abbe2d 100755 --- a/internal/sdk/pkg/models/operations/createconnection.go +++ b/internal/sdk/pkg/models/operations/createconnection.go @@ -9,10 +9,13 @@ import ( type CreateConnectionResponse struct { // Created - Connection *shared.Connection + Connection *shared.Connection + // HTTP response content type for this operation ContentType string // Request Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createdemo.go b/internal/sdk/pkg/models/operations/createdemo.go index 04ee410..9af21a2 100755 --- a/internal/sdk/pkg/models/operations/createdemo.go +++ b/internal/sdk/pkg/models/operations/createdemo.go @@ -8,11 +8,14 @@ import ( ) type CreateDemoResponse struct { + // HTTP response content type for this operation ContentType string // Created Demo *shared.Demo // Request Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createdirectory.go b/internal/sdk/pkg/models/operations/createdirectory.go new file mode 100755 index 0000000..705aab6 --- /dev/null +++ b/internal/sdk/pkg/models/operations/createdirectory.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CreateDirectoryResponse struct { + // HTTP response content type for this operation + ContentType string + // Created + DirectorySync *shared.DirectorySync + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/creategheapp.go b/internal/sdk/pkg/models/operations/creategheapp.go new file mode 100755 index 0000000..dcbb02d --- /dev/null +++ b/internal/sdk/pkg/models/operations/creategheapp.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CreateGHEAppResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Created + GithubEnterpriseApp *shared.GithubEnterpriseApp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/creategrantkit.go b/internal/sdk/pkg/models/operations/creategrantkit.go index db6772c..0fe6bb3 100755 --- a/internal/sdk/pkg/models/operations/creategrantkit.go +++ b/internal/sdk/pkg/models/operations/creategrantkit.go @@ -8,11 +8,14 @@ import ( ) type CreateGrantKitResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Created - GrantKit *shared.GrantKit - StatusCode int + GrantKit *shared.GrantKit + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createidentity.go b/internal/sdk/pkg/models/operations/createidentity.go index 12638e9..f7c5e46 100755 --- a/internal/sdk/pkg/models/operations/createidentity.go +++ b/internal/sdk/pkg/models/operations/createidentity.go @@ -8,11 +8,14 @@ import ( ) type CreateIdentityResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Created - Identity *shared.Identity - StatusCode int + Identity *shared.Identity + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createoauth.go b/internal/sdk/pkg/models/operations/createoauth.go new file mode 100755 index 0000000..652fcbd --- /dev/null +++ b/internal/sdk/pkg/models/operations/createoauth.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CreateOAuthResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/createrequest.go b/internal/sdk/pkg/models/operations/createrequest.go index 51b1271..ac32aae 100755 --- a/internal/sdk/pkg/models/operations/createrequest.go +++ b/internal/sdk/pkg/models/operations/createrequest.go @@ -8,11 +8,14 @@ import ( ) type CreateRequestResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Created - Request *shared.Request - StatusCode int + Request *shared.Request + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/createsamlconnection.go b/internal/sdk/pkg/models/operations/createsamlconnection.go new file mode 100755 index 0000000..eb4a568 --- /dev/null +++ b/internal/sdk/pkg/models/operations/createsamlconnection.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type CreateSamlConnectionResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Created + SamlConnection *shared.SamlConnection + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/deleteapikey.go b/internal/sdk/pkg/models/operations/deleteapikey.go index c2434dc..b6fa0e1 100755 --- a/internal/sdk/pkg/models/operations/deleteapikey.go +++ b/internal/sdk/pkg/models/operations/deleteapikey.go @@ -13,9 +13,12 @@ type DeleteAPIKeyRequest struct { } type DeleteAPIKeyResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/deletedemo.go b/internal/sdk/pkg/models/operations/deletedemo.go index e4b1368..be2d117 100755 --- a/internal/sdk/pkg/models/operations/deletedemo.go +++ b/internal/sdk/pkg/models/operations/deletedemo.go @@ -8,11 +8,14 @@ import ( ) type DeleteDemoResponse struct { + // HTTP response content type for this operation ContentType string // Success Demo *shared.Demo // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/deletedirectory.go b/internal/sdk/pkg/models/operations/deletedirectory.go new file mode 100755 index 0000000..43dbd5c --- /dev/null +++ b/internal/sdk/pkg/models/operations/deletedirectory.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type DeleteDirectoryResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/deletegheapp.go b/internal/sdk/pkg/models/operations/deletegheapp.go new file mode 100755 index 0000000..a40b805 --- /dev/null +++ b/internal/sdk/pkg/models/operations/deletegheapp.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type DeleteGHEAppRequest struct { + // The ID of the connection to update + AppID string `pathParam:"style=simple,explode=false,name=app_id"` +} + +type DeleteGHEAppResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/deletegrantkit.go b/internal/sdk/pkg/models/operations/deletegrantkit.go index edd68f2..12d8935 100755 --- a/internal/sdk/pkg/models/operations/deletegrantkit.go +++ b/internal/sdk/pkg/models/operations/deletegrantkit.go @@ -13,11 +13,14 @@ type DeleteGrantKitRequest struct { } type DeleteGrantKitResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - GrantKit *shared.GrantKit - StatusCode int + GrantKit *shared.GrantKit + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/deleteidentity.go b/internal/sdk/pkg/models/operations/deleteidentity.go index 7061c50..ef6f9ad 100755 --- a/internal/sdk/pkg/models/operations/deleteidentity.go +++ b/internal/sdk/pkg/models/operations/deleteidentity.go @@ -13,9 +13,12 @@ type DeleteIdentityRequest struct { } type DeleteIdentityResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/deletesamlconnectionbyid.go b/internal/sdk/pkg/models/operations/deletesamlconnectionbyid.go new file mode 100755 index 0000000..5ed647a --- /dev/null +++ b/internal/sdk/pkg/models/operations/deletesamlconnectionbyid.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type DeleteSamlConnectionByIDRequest struct { + // The ID of the SAML connection to update + SamlConnectionID string `pathParam:"style=simple,explode=false,name=saml_connection_id"` +} + +type DeleteSamlConnectionByIDResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/denyreview.go b/internal/sdk/pkg/models/operations/denyreview.go index 3d56b9a..3189d7e 100755 --- a/internal/sdk/pkg/models/operations/denyreview.go +++ b/internal/sdk/pkg/models/operations/denyreview.go @@ -14,11 +14,14 @@ type DenyReviewRequest struct { } type DenyReviewResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Success - Review *shared.Review - StatusCode int + Review *shared.Review + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getapikeys.go b/internal/sdk/pkg/models/operations/getapikeys.go index 7168cfd..6318140 100755 --- a/internal/sdk/pkg/models/operations/getapikeys.go +++ b/internal/sdk/pkg/models/operations/getapikeys.go @@ -9,10 +9,13 @@ import ( type GetAPIKeysResponse struct { // Success - APIKeys *shared.APIKeys + APIKeys *shared.APIKeys + // HTTP response content type for this operation ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getconnection.go b/internal/sdk/pkg/models/operations/getconnection.go index fd80303..01dfc8a 100755 --- a/internal/sdk/pkg/models/operations/getconnection.go +++ b/internal/sdk/pkg/models/operations/getconnection.go @@ -14,10 +14,13 @@ type GetConnectionRequest struct { type GetConnectionResponse struct { // Success - Connection *shared.Connection + Connection *shared.Connection + // HTTP response content type for this operation ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getdemo.go b/internal/sdk/pkg/models/operations/getdemo.go index 4146d67..88fb539 100755 --- a/internal/sdk/pkg/models/operations/getdemo.go +++ b/internal/sdk/pkg/models/operations/getdemo.go @@ -7,12 +7,20 @@ import ( "net/http" ) +type GetDemoRequest struct { + // The email of the user + Email string `queryParam:"style=form,explode=true,name=email"` +} + type GetDemoResponse struct { + // HTTP response content type for this operation ContentType string // Success Demo *shared.Demo // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getdirectory.go b/internal/sdk/pkg/models/operations/getdirectory.go new file mode 100755 index 0000000..5a7618e --- /dev/null +++ b/internal/sdk/pkg/models/operations/getdirectory.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type GetDirectoryResponse struct { + // HTTP response content type for this operation + ContentType string + // Success + DirectorySync *shared.DirectorySync + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/getgheapp.go b/internal/sdk/pkg/models/operations/getgheapp.go new file mode 100755 index 0000000..4038868 --- /dev/null +++ b/internal/sdk/pkg/models/operations/getgheapp.go @@ -0,0 +1,26 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type GetGHEAppRequest struct { + // The ID of the connection to retrieve + AppID string `pathParam:"style=simple,explode=false,name=app_id"` +} + +type GetGHEAppResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + GithubEnterpriseApp *shared.GithubEnterpriseApp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/getgrantbyid.go b/internal/sdk/pkg/models/operations/getgrantbyid.go index 5723e6b..41f7a12 100755 --- a/internal/sdk/pkg/models/operations/getgrantbyid.go +++ b/internal/sdk/pkg/models/operations/getgrantbyid.go @@ -13,11 +13,14 @@ type GetGrantByIDRequest struct { } type GetGrantByIDResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Grant *shared.Grant - StatusCode int + Grant *shared.Grant + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getgrantkitbyid.go b/internal/sdk/pkg/models/operations/getgrantkitbyid.go index 4cc383a..6d5e19b 100755 --- a/internal/sdk/pkg/models/operations/getgrantkitbyid.go +++ b/internal/sdk/pkg/models/operations/getgrantkitbyid.go @@ -13,11 +13,14 @@ type GetGrantKitByIDRequest struct { } type GetGrantKitByIDResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - GrantKit *shared.GrantKit - StatusCode int + GrantKit *shared.GrantKit + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getidentity.go b/internal/sdk/pkg/models/operations/getidentity.go index 2860a96..94406c2 100755 --- a/internal/sdk/pkg/models/operations/getidentity.go +++ b/internal/sdk/pkg/models/operations/getidentity.go @@ -13,11 +13,14 @@ type GetIdentityRequest struct { } type GetIdentityResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Identity *shared.Identity - StatusCode int + Identity *shared.Identity + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getportallink.go b/internal/sdk/pkg/models/operations/getportallink.go new file mode 100755 index 0000000..86d3b33 --- /dev/null +++ b/internal/sdk/pkg/models/operations/getportallink.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type GetPortalLinkResponse struct { + // HTTP response content type for this operation + ContentType string + // Success + DirectorySyncAdminPortal *shared.DirectorySyncAdminPortal + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/getrequestbyid.go b/internal/sdk/pkg/models/operations/getrequestbyid.go index 657c541..b50f380 100755 --- a/internal/sdk/pkg/models/operations/getrequestbyid.go +++ b/internal/sdk/pkg/models/operations/getrequestbyid.go @@ -13,11 +13,14 @@ type GetRequestByIDRequest struct { } type GetRequestByIDResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Request *shared.Request - StatusCode int + Request *shared.Request + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getreviewbyid.go b/internal/sdk/pkg/models/operations/getreviewbyid.go index b78c9b2..8265d67 100755 --- a/internal/sdk/pkg/models/operations/getreviewbyid.go +++ b/internal/sdk/pkg/models/operations/getreviewbyid.go @@ -13,11 +13,14 @@ type GetReviewByIDRequest struct { } type GetReviewByIDResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Review *shared.Review - StatusCode int + Review *shared.Review + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/getsamlconnectionbyid.go b/internal/sdk/pkg/models/operations/getsamlconnectionbyid.go new file mode 100755 index 0000000..0a9c08c --- /dev/null +++ b/internal/sdk/pkg/models/operations/getsamlconnectionbyid.go @@ -0,0 +1,26 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type GetSamlConnectionByIDRequest struct { + // The ID of the SAML connection to retrieve + SamlConnectionID string `pathParam:"style=simple,explode=false,name=saml_connection_id"` +} + +type GetSamlConnectionByIDResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + SamlConnection *shared.SamlConnection + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/listconnections.go b/internal/sdk/pkg/models/operations/listconnections.go index 3426a27..b601809 100755 --- a/internal/sdk/pkg/models/operations/listconnections.go +++ b/internal/sdk/pkg/models/operations/listconnections.go @@ -10,9 +10,12 @@ import ( type ListConnectionsResponse struct { // Success ConnectionListing *shared.ConnectionListing - ContentType string + // HTTP response content type for this operation + ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listconnectionspecs.go b/internal/sdk/pkg/models/operations/listconnectionspecs.go index 193de3c..66e7630 100755 --- a/internal/sdk/pkg/models/operations/listconnectionspecs.go +++ b/internal/sdk/pkg/models/operations/listconnectionspecs.go @@ -10,9 +10,12 @@ import ( type ListConnectionSpecsResponse struct { // Success ConnectionSpecListing *shared.ConnectionSpecListing - ContentType string + // HTTP response content type for this operation + ContentType string // Authentication Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listenrichedidentities.go b/internal/sdk/pkg/models/operations/listenrichedidentities.go new file mode 100755 index 0000000..eba542d --- /dev/null +++ b/internal/sdk/pkg/models/operations/listenrichedidentities.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type ListEnrichedIdentitiesResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + Identities []shared.Identity + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/listgheapp.go b/internal/sdk/pkg/models/operations/listgheapp.go new file mode 100755 index 0000000..b341cc5 --- /dev/null +++ b/internal/sdk/pkg/models/operations/listgheapp.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type ListGHEAppResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + GithubEnterpriseApps []shared.GithubEnterpriseApp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/listgrantkits.go b/internal/sdk/pkg/models/operations/listgrantkits.go index 4df5c3c..dd93154 100755 --- a/internal/sdk/pkg/models/operations/listgrantkits.go +++ b/internal/sdk/pkg/models/operations/listgrantkits.go @@ -8,11 +8,14 @@ import ( ) type ListGrantKitsResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - GrantKits []shared.GrantKit - StatusCode int + GrantKits []shared.GrantKit + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listgrantkitversionsbyid.go b/internal/sdk/pkg/models/operations/listgrantkitversionsbyid.go index ebe3fe7..78207fc 100755 --- a/internal/sdk/pkg/models/operations/listgrantkitversionsbyid.go +++ b/internal/sdk/pkg/models/operations/listgrantkitversionsbyid.go @@ -13,11 +13,14 @@ type ListGrantKitVersionsByIDRequest struct { } type ListGrantKitVersionsByIDResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success GrantKitVersions []shared.GrantKitVersion - StatusCode int - RawResponse *http.Response + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listgrants.go b/internal/sdk/pkg/models/operations/listgrants.go index e4d0c52..820ef6d 100755 --- a/internal/sdk/pkg/models/operations/listgrants.go +++ b/internal/sdk/pkg/models/operations/listgrants.go @@ -8,11 +8,14 @@ import ( ) type ListGrantsResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Grants []shared.Grant - StatusCode int + Grants []shared.Grant + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listoauths.go b/internal/sdk/pkg/models/operations/listoauths.go new file mode 100755 index 0000000..e8d2536 --- /dev/null +++ b/internal/sdk/pkg/models/operations/listoauths.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type ListOauthsResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + OauthListing *shared.OauthListing + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/listrequests.go b/internal/sdk/pkg/models/operations/listrequests.go index 834bac2..6b4296e 100755 --- a/internal/sdk/pkg/models/operations/listrequests.go +++ b/internal/sdk/pkg/models/operations/listrequests.go @@ -8,11 +8,14 @@ import ( ) type ListRequestsResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Requests []shared.Request - StatusCode int + Requests []shared.Request + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listreviews.go b/internal/sdk/pkg/models/operations/listreviews.go index 1d85442..4ca104c 100755 --- a/internal/sdk/pkg/models/operations/listreviews.go +++ b/internal/sdk/pkg/models/operations/listreviews.go @@ -8,11 +8,14 @@ import ( ) type ListReviewsResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Reviews []shared.Review - StatusCode int + Reviews []shared.Review + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/listsamlconnections.go b/internal/sdk/pkg/models/operations/listsamlconnections.go new file mode 100755 index 0000000..79e22bb --- /dev/null +++ b/internal/sdk/pkg/models/operations/listsamlconnections.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type ListSamlConnectionsResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + SamlConnections *shared.SamlConnections + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/revokegrant.go b/internal/sdk/pkg/models/operations/revokegrant.go index bffe863..332a189 100755 --- a/internal/sdk/pkg/models/operations/revokegrant.go +++ b/internal/sdk/pkg/models/operations/revokegrant.go @@ -13,11 +13,14 @@ type RevokeGrantRequest struct { } type RevokeGrantResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Success - Grant *shared.Grant - StatusCode int + Grant *shared.Grant + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/slackcommand.go b/internal/sdk/pkg/models/operations/slackcommand.go new file mode 100755 index 0000000..2301e71 --- /dev/null +++ b/internal/sdk/pkg/models/operations/slackcommand.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type SlackCommandResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Success + OauthListing *shared.OauthListing + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/updateconnection.go b/internal/sdk/pkg/models/operations/updateconnection.go index ba58f6a..e1962b0 100755 --- a/internal/sdk/pkg/models/operations/updateconnection.go +++ b/internal/sdk/pkg/models/operations/updateconnection.go @@ -15,10 +15,13 @@ type UpdateConnectionRequest struct { type UpdateConnectionResponse struct { // Success - Connection *shared.Connection + Connection *shared.Connection + // HTTP response content type for this operation ContentType string // Request Failed - Error *shared.Error - StatusCode int + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/updatedirectory.go b/internal/sdk/pkg/models/operations/updatedirectory.go new file mode 100755 index 0000000..c6b7e79 --- /dev/null +++ b/internal/sdk/pkg/models/operations/updatedirectory.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type UpdateDirectoryResponse struct { + // HTTP response content type for this operation + ContentType string + // Created + DirectorySync *shared.DirectorySync + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/updategheapp.go b/internal/sdk/pkg/models/operations/updategheapp.go new file mode 100755 index 0000000..de7d7f3 --- /dev/null +++ b/internal/sdk/pkg/models/operations/updategheapp.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type UpdateGHEAppRequest struct { + GithubEnterpriseAppParams shared.GithubEnterpriseAppParams `request:"mediaType=application/json"` + // The ID of the connection to update + AppID string `pathParam:"style=simple,explode=false,name=app_id"` +} + +type UpdateGHEAppResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // Success + GithubEnterpriseApp *shared.GithubEnterpriseApp + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/updategrantkit.go b/internal/sdk/pkg/models/operations/updategrantkit.go index 464c90c..0ed1095 100755 --- a/internal/sdk/pkg/models/operations/updategrantkit.go +++ b/internal/sdk/pkg/models/operations/updategrantkit.go @@ -14,11 +14,14 @@ type UpdateGrantKitRequest struct { } type UpdateGrantKitResponse struct { + // HTTP response content type for this operation ContentType string // Request Failed Error *shared.Error // Success - GrantKit *shared.GrantKit - StatusCode int + GrantKit *shared.GrantKit + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/updateidentity.go b/internal/sdk/pkg/models/operations/updateidentity.go index ffb6532..33f62da 100755 --- a/internal/sdk/pkg/models/operations/updateidentity.go +++ b/internal/sdk/pkg/models/operations/updateidentity.go @@ -14,11 +14,14 @@ type UpdateIdentityRequest struct { } type UpdateIdentityResponse struct { + // HTTP response content type for this operation ContentType string // Authentication Failed Error *shared.Error // Success - Identity *shared.Identity - StatusCode int + Identity *shared.Identity + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } diff --git a/internal/sdk/pkg/models/operations/updatesamlconnectionbyid.go b/internal/sdk/pkg/models/operations/updatesamlconnectionbyid.go new file mode 100755 index 0000000..dad5bec --- /dev/null +++ b/internal/sdk/pkg/models/operations/updatesamlconnectionbyid.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type UpdateSamlConnectionByIDRequest struct { + SamlConnectionUpdateParams shared.SamlConnectionUpdateParams `request:"mediaType=application/json"` + // The ID of the SAML connection to update + SamlConnectionID string `pathParam:"style=simple,explode=false,name=saml_connection_id"` +} + +type UpdateSamlConnectionByIDResponse struct { + // HTTP response content type for this operation + ContentType string + // Authentication Failed + Error *shared.Error + // Success + SamlConnection *shared.SamlConnection + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/workosdirectorieswebhook.go b/internal/sdk/pkg/models/operations/workosdirectorieswebhook.go new file mode 100755 index 0000000..a9e585f --- /dev/null +++ b/internal/sdk/pkg/models/operations/workosdirectorieswebhook.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type WorkOSDirectoriesWebhookResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/workosgroupswebhook.go b/internal/sdk/pkg/models/operations/workosgroupswebhook.go new file mode 100755 index 0000000..80dcfe9 --- /dev/null +++ b/internal/sdk/pkg/models/operations/workosgroupswebhook.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type WorkOSGroupsWebhookResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/operations/workosuserswebhook.go b/internal/sdk/pkg/models/operations/workosuserswebhook.go new file mode 100755 index 0000000..eaaad0f --- /dev/null +++ b/internal/sdk/pkg/models/operations/workosuserswebhook.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package operations + +import ( + "abbey/v2/internal/sdk/pkg/models/shared" + "net/http" +) + +type WorkOSUsersWebhookResponse struct { + // HTTP response content type for this operation + ContentType string + // Request Failed + Error *shared.Error + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} diff --git a/internal/sdk/pkg/models/shared/apikey.go b/internal/sdk/pkg/models/shared/apikey.go index 145c722..2c7cf7b 100755 --- a/internal/sdk/pkg/models/shared/apikey.go +++ b/internal/sdk/pkg/models/shared/apikey.go @@ -6,7 +6,6 @@ import ( "time" ) -// APIKey - Created type APIKey struct { APIKey string `json:"api_key"` Expired bool `json:"expired"` diff --git a/internal/sdk/pkg/models/shared/apikeys.go b/internal/sdk/pkg/models/shared/apikeys.go index b165eff..8474fd6 100755 --- a/internal/sdk/pkg/models/shared/apikeys.go +++ b/internal/sdk/pkg/models/shared/apikeys.go @@ -2,7 +2,6 @@ package shared -// APIKeys - Success type APIKeys struct { Items []APIKey `json:"items"` } diff --git a/internal/sdk/pkg/models/shared/connection.go b/internal/sdk/pkg/models/shared/connection.go index 2501a0d..5712d2b 100755 --- a/internal/sdk/pkg/models/shared/connection.go +++ b/internal/sdk/pkg/models/shared/connection.go @@ -6,7 +6,6 @@ import ( "time" ) -// Connection - Created type Connection struct { CreatedAt time.Time `json:"created_at"` ID string `json:"id"` diff --git a/internal/sdk/pkg/models/shared/connectionauth.go b/internal/sdk/pkg/models/shared/connectionauth.go index c9a2792..1ed8f03 100755 --- a/internal/sdk/pkg/models/shared/connectionauth.go +++ b/internal/sdk/pkg/models/shared/connectionauth.go @@ -9,6 +9,17 @@ import ( "fmt" ) +type ConnectionAuthOauth2Flow struct { + CallbackQueryParams []string `json:"callback_query_params,omitempty"` + ConnectionAuthTypeEnum *ConnectionAuthTypeEnum `json:"type,omitempty"` + // Describes how the client should conduct the authorization code exchange. + // + Exchange *Oauth2FlowExchange `json:"exchange,omitempty"` + Pkce *Oauth2FlowPkce `json:"pkce,omitempty"` + QueryParams []KeyValuePair `json:"query_params,omitempty"` + URL string `json:"url"` +} + type ConnectionAuthType string const ( @@ -16,19 +27,19 @@ const ( ) type ConnectionAuth struct { - Oauth2Flow *Oauth2Flow + ConnectionAuthOauth2Flow *ConnectionAuthOauth2Flow Type ConnectionAuthType } -func CreateConnectionAuthOauth2(oauth2 Oauth2Flow) ConnectionAuth { +func CreateConnectionAuthOauth2(oauth2 ConnectionAuthOauth2Flow) ConnectionAuth { typ := ConnectionAuthTypeOauth2 typStr := ConnectionAuthTypeEnum(typ) oauth2.ConnectionAuthTypeEnum = &typStr return ConnectionAuth{ - Oauth2Flow: &oauth2, - Type: typ, + ConnectionAuthOauth2Flow: &oauth2, + Type: typ, } } @@ -47,12 +58,12 @@ func (u *ConnectionAuth) UnmarshalJSON(data []byte) error { switch dis.ConnectionAuthTypeEnum { case "Oauth2": d = json.NewDecoder(bytes.NewReader(data)) - oauth2Flow := new(Oauth2Flow) - if err := d.Decode(&oauth2Flow); err != nil { + connectionAuthOauth2Flow := new(ConnectionAuthOauth2Flow) + if err := d.Decode(&connectionAuthOauth2Flow); err != nil { return fmt.Errorf("could not unmarshal expected type: %w", err) } - u.Oauth2Flow = oauth2Flow + u.ConnectionAuthOauth2Flow = connectionAuthOauth2Flow u.Type = ConnectionAuthTypeOauth2 return nil } @@ -61,8 +72,8 @@ func (u *ConnectionAuth) UnmarshalJSON(data []byte) error { } func (u ConnectionAuth) MarshalJSON() ([]byte, error) { - if u.Oauth2Flow != nil { - return json.Marshal(u.Oauth2Flow) + if u.ConnectionAuthOauth2Flow != nil { + return json.Marshal(u.ConnectionAuthOauth2Flow) } return nil, nil diff --git a/internal/sdk/pkg/models/shared/connectionlisting.go b/internal/sdk/pkg/models/shared/connectionlisting.go index 3bfe855..b066b9a 100755 --- a/internal/sdk/pkg/models/shared/connectionlisting.go +++ b/internal/sdk/pkg/models/shared/connectionlisting.go @@ -2,7 +2,6 @@ package shared -// ConnectionListing - Success type ConnectionListing struct { Items []Connection `json:"items"` Next *string `json:"next,omitempty"` diff --git a/internal/sdk/pkg/models/shared/connectionparams.go b/internal/sdk/pkg/models/shared/connectionparams.go index 8b7fe66..b5f077e 100755 --- a/internal/sdk/pkg/models/shared/connectionparams.go +++ b/internal/sdk/pkg/models/shared/connectionparams.go @@ -9,39 +9,73 @@ import ( "fmt" ) +type ConnectionParamsGithubEnterpriseConnectionValue struct { + Hostname *string `json:"hostname,omitempty"` + Name *string `json:"name,omitempty"` + Type ConnectionType `json:"type"` + Value GithubEnterpriseConnection `json:"value"` +} + +type ConnectionParamsPagerdutyConnectionValue struct { + Hostname *string `json:"hostname,omitempty"` + Name *string `json:"name,omitempty"` + Type ConnectionType `json:"type"` + Value PagerdutyConnection `json:"value"` +} + +type ConnectionParamsConnectionParamsGithubVariant struct { + Hostname *string `json:"hostname,omitempty"` + Name *string `json:"name,omitempty"` + Type ConnectionType `json:"type"` + Value ConnectionParamsGithub `json:"value"` +} + type ConnectionParamsType string const ( - ConnectionParamsTypeGithub ConnectionParamsType = "Github" - ConnectionParamsTypePagerduty ConnectionParamsType = "Pagerduty" + ConnectionParamsTypeGithub ConnectionParamsType = "Github" + ConnectionParamsTypeGithubEnterprise ConnectionParamsType = "GithubEnterprise" + ConnectionParamsTypePagerduty ConnectionParamsType = "Pagerduty" ) type ConnectionParams struct { - ConnectionParamsGithubVariant *ConnectionParamsGithubVariant - PagerdutyConnectionValue *PagerdutyConnectionValue + ConnectionParamsConnectionParamsGithubVariant *ConnectionParamsConnectionParamsGithubVariant + ConnectionParamsPagerdutyConnectionValue *ConnectionParamsPagerdutyConnectionValue + ConnectionParamsGithubEnterpriseConnectionValue *ConnectionParamsGithubEnterpriseConnectionValue Type ConnectionParamsType } -func CreateConnectionParamsGithub(github ConnectionParamsGithubVariant) ConnectionParams { +func CreateConnectionParamsGithub(github ConnectionParamsConnectionParamsGithubVariant) ConnectionParams { typ := ConnectionParamsTypeGithub typStr := ConnectionType(typ) github.Type = typStr return ConnectionParams{ - ConnectionParamsGithubVariant: &github, - Type: typ, + ConnectionParamsConnectionParamsGithubVariant: &github, + Type: typ, } } -func CreateConnectionParamsPagerduty(pagerduty PagerdutyConnectionValue) ConnectionParams { +func CreateConnectionParamsGithubEnterprise(githubEnterprise ConnectionParamsGithubEnterpriseConnectionValue) ConnectionParams { + typ := ConnectionParamsTypeGithubEnterprise + typStr := ConnectionType(typ) + githubEnterprise.Type = typStr + + return ConnectionParams{ + ConnectionParamsGithubEnterpriseConnectionValue: &githubEnterprise, + Type: typ, + } +} + +func CreateConnectionParamsPagerduty(pagerduty ConnectionParamsPagerdutyConnectionValue) ConnectionParams { typ := ConnectionParamsTypePagerduty typStr := ConnectionType(typ) pagerduty.Type = typStr return ConnectionParams{ - PagerdutyConnectionValue: &pagerduty, - Type: typ, + ConnectionParamsPagerdutyConnectionValue: &pagerduty, + Type: typ, } } @@ -60,22 +94,32 @@ func (u *ConnectionParams) UnmarshalJSON(data []byte) error { switch dis.Type { case "Github": d = json.NewDecoder(bytes.NewReader(data)) - connectionParamsGithubVariant := new(ConnectionParamsGithubVariant) - if err := d.Decode(&connectionParamsGithubVariant); err != nil { + connectionParamsConnectionParamsGithubVariant := new(ConnectionParamsConnectionParamsGithubVariant) + if err := d.Decode(&connectionParamsConnectionParamsGithubVariant); err != nil { return fmt.Errorf("could not unmarshal expected type: %w", err) } - u.ConnectionParamsGithubVariant = connectionParamsGithubVariant + u.ConnectionParamsConnectionParamsGithubVariant = connectionParamsConnectionParamsGithubVariant u.Type = ConnectionParamsTypeGithub return nil + case "GithubEnterprise": + d = json.NewDecoder(bytes.NewReader(data)) + connectionParamsGithubEnterpriseConnectionValue := new(ConnectionParamsGithubEnterpriseConnectionValue) + if err := d.Decode(&connectionParamsGithubEnterpriseConnectionValue); err != nil { + return fmt.Errorf("could not unmarshal expected type: %w", err) + } + + u.ConnectionParamsGithubEnterpriseConnectionValue = connectionParamsGithubEnterpriseConnectionValue + u.Type = ConnectionParamsTypeGithubEnterprise + return nil case "Pagerduty": d = json.NewDecoder(bytes.NewReader(data)) - pagerdutyConnectionValue := new(PagerdutyConnectionValue) - if err := d.Decode(&pagerdutyConnectionValue); err != nil { + connectionParamsPagerdutyConnectionValue := new(ConnectionParamsPagerdutyConnectionValue) + if err := d.Decode(&connectionParamsPagerdutyConnectionValue); err != nil { return fmt.Errorf("could not unmarshal expected type: %w", err) } - u.PagerdutyConnectionValue = pagerdutyConnectionValue + u.ConnectionParamsPagerdutyConnectionValue = connectionParamsPagerdutyConnectionValue u.Type = ConnectionParamsTypePagerduty return nil } @@ -84,12 +128,16 @@ func (u *ConnectionParams) UnmarshalJSON(data []byte) error { } func (u ConnectionParams) MarshalJSON() ([]byte, error) { - if u.ConnectionParamsGithubVariant != nil { - return json.Marshal(u.ConnectionParamsGithubVariant) + if u.ConnectionParamsConnectionParamsGithubVariant != nil { + return json.Marshal(u.ConnectionParamsConnectionParamsGithubVariant) + } + + if u.ConnectionParamsPagerdutyConnectionValue != nil { + return json.Marshal(u.ConnectionParamsPagerdutyConnectionValue) } - if u.PagerdutyConnectionValue != nil { - return json.Marshal(u.PagerdutyConnectionValue) + if u.ConnectionParamsGithubEnterpriseConnectionValue != nil { + return json.Marshal(u.ConnectionParamsGithubEnterpriseConnectionValue) } return nil, nil diff --git a/internal/sdk/pkg/models/shared/connectionparamsgithubvariant.go b/internal/sdk/pkg/models/shared/connectionparamsgithubvariant.go deleted file mode 100755 index dfbc8e8..0000000 --- a/internal/sdk/pkg/models/shared/connectionparamsgithubvariant.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package shared - -type ConnectionParamsGithubVariant struct { - Name *string `json:"name,omitempty"` - Type ConnectionType `json:"type"` - Value ConnectionParamsGithub `json:"value"` -} diff --git a/internal/sdk/pkg/models/shared/connectionspeclisting.go b/internal/sdk/pkg/models/shared/connectionspeclisting.go index b0f46f3..b621053 100755 --- a/internal/sdk/pkg/models/shared/connectionspeclisting.go +++ b/internal/sdk/pkg/models/shared/connectionspeclisting.go @@ -2,7 +2,6 @@ package shared -// ConnectionSpecListing - Success type ConnectionSpecListing struct { Items []ConnectionSpec `json:"items"` Next *string `json:"next,omitempty"` diff --git a/internal/sdk/pkg/models/shared/connectiontype.go b/internal/sdk/pkg/models/shared/connectiontype.go index 1ba1d91..06c78b1 100755 --- a/internal/sdk/pkg/models/shared/connectiontype.go +++ b/internal/sdk/pkg/models/shared/connectiontype.go @@ -10,8 +10,9 @@ import ( type ConnectionType string const ( - ConnectionTypeGithub ConnectionType = "Github" - ConnectionTypePagerduty ConnectionType = "Pagerduty" + ConnectionTypeGithub ConnectionType = "Github" + ConnectionTypePagerduty ConnectionType = "Pagerduty" + ConnectionTypeGithubEnterprise ConnectionType = "GithubEnterprise" ) func (e ConnectionType) ToPointer() *ConnectionType { @@ -27,6 +28,8 @@ func (e *ConnectionType) UnmarshalJSON(data []byte) error { case "Github": fallthrough case "Pagerduty": + fallthrough + case "GithubEnterprise": *e = ConnectionType(v) return nil default: diff --git a/internal/sdk/pkg/models/shared/demo.go b/internal/sdk/pkg/models/shared/demo.go index fd0c91f..9b72b44 100755 --- a/internal/sdk/pkg/models/shared/demo.go +++ b/internal/sdk/pkg/models/shared/demo.go @@ -6,7 +6,6 @@ import ( "time" ) -// Demo - Success type Demo struct { CreatedAt *time.Time `json:"created_at,omitempty"` ID *int64 `json:"id,omitempty"` diff --git a/internal/sdk/pkg/models/shared/demoparams.go b/internal/sdk/pkg/models/shared/demoparams.go index 4df2060..a20f3df 100755 --- a/internal/sdk/pkg/models/shared/demoparams.go +++ b/internal/sdk/pkg/models/shared/demoparams.go @@ -32,6 +32,6 @@ func (e *DemoParamsPermission) UnmarshalJSON(data []byte) error { } type DemoParams struct { - Email string `json:"email"` - Permission DemoParamsPermission `json:"permission"` + Email string `json:"email"` + Permission *DemoParamsPermission `json:"permission,omitempty"` } diff --git a/internal/sdk/pkg/models/shared/directorysync.go b/internal/sdk/pkg/models/shared/directorysync.go new file mode 100755 index 0000000..8d52d11 --- /dev/null +++ b/internal/sdk/pkg/models/shared/directorysync.go @@ -0,0 +1,17 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type DirectorySync struct { + CreatedAt time.Time `json:"created_at"` + DirectoryID string `json:"directory_id"` + Domains []string `json:"domains,omitempty"` + ID string `json:"id"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + UpdatedAt time.Time `json:"updated_at"` +} diff --git a/internal/sdk/pkg/models/shared/directorysyncadminportal.go b/internal/sdk/pkg/models/shared/directorysyncadminportal.go new file mode 100755 index 0000000..565d9c6 --- /dev/null +++ b/internal/sdk/pkg/models/shared/directorysyncadminportal.go @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type DirectorySyncAdminPortal struct { + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Link *string `json:"link,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/directorysyncparams.go b/internal/sdk/pkg/models/shared/directorysyncparams.go new file mode 100755 index 0000000..00af7ea --- /dev/null +++ b/internal/sdk/pkg/models/shared/directorysyncparams.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type DirectorySyncParams struct { + Domain string `json:"domain"` + Name string `json:"name"` +} diff --git a/internal/sdk/pkg/models/shared/error.go b/internal/sdk/pkg/models/shared/error.go index b8ec694..78eab70 100755 --- a/internal/sdk/pkg/models/shared/error.go +++ b/internal/sdk/pkg/models/shared/error.go @@ -2,7 +2,6 @@ package shared -// Error - Authentication Failed type Error struct { Code string `json:"code"` DocURL *string `json:"doc_url,omitempty"` diff --git a/internal/sdk/pkg/models/shared/githubenterpriseapp.go b/internal/sdk/pkg/models/shared/githubenterpriseapp.go new file mode 100755 index 0000000..f856e18 --- /dev/null +++ b/internal/sdk/pkg/models/shared/githubenterpriseapp.go @@ -0,0 +1,9 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type GithubEnterpriseApp struct { + Hostname *string `json:"hostname,omitempty"` + ID *string `json:"id,omitempty"` + Org *string `json:"org,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/githubenterpriseappparams.go b/internal/sdk/pkg/models/shared/githubenterpriseappparams.go new file mode 100755 index 0000000..ac515b8 --- /dev/null +++ b/internal/sdk/pkg/models/shared/githubenterpriseappparams.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type GithubEnterpriseAppParams struct { + ClientID *string `json:"client_id,omitempty"` + Hostname *string `json:"hostname,omitempty"` + ID *string `json:"id,omitempty"` + Org *string `json:"org,omitempty"` + Pem *string `json:"pem,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/githubenterpriseconnection.go b/internal/sdk/pkg/models/shared/githubenterpriseconnection.go new file mode 100755 index 0000000..96f11d6 --- /dev/null +++ b/internal/sdk/pkg/models/shared/githubenterpriseconnection.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type GithubEnterpriseConnection struct { + InstallationID string `json:"installation_id"` +} diff --git a/internal/sdk/pkg/models/shared/grant.go b/internal/sdk/pkg/models/shared/grant.go index 8e54d58..1518043 100755 --- a/internal/sdk/pkg/models/shared/grant.go +++ b/internal/sdk/pkg/models/shared/grant.go @@ -6,7 +6,6 @@ import ( "time" ) -// Grant - Success type Grant struct { CreatedAt time.Time `json:"created_at"` Deleted bool `json:"deleted"` diff --git a/internal/sdk/pkg/models/shared/grantkit.go b/internal/sdk/pkg/models/shared/grantkit.go index 64220e9..cf03106 100755 --- a/internal/sdk/pkg/models/shared/grantkit.go +++ b/internal/sdk/pkg/models/shared/grantkit.go @@ -6,7 +6,6 @@ import ( "time" ) -// GrantKit - Created type GrantKit struct { CreatedAt time.Time `json:"created_at"` CurrentVersionID string `json:"current_version_id"` diff --git a/internal/sdk/pkg/models/shared/grantkitversion.go b/internal/sdk/pkg/models/shared/grantkitversion.go index d21388c..d3d7748 100755 --- a/internal/sdk/pkg/models/shared/grantkitversion.go +++ b/internal/sdk/pkg/models/shared/grantkitversion.go @@ -7,14 +7,14 @@ import ( ) type GrantKitVersion struct { - CreatedAt time.Time `json:"created_at"` - Description string `json:"description"` - GrantKitID string `json:"grant_kit_id"` - GrantKitName string `json:"grant_kit_name"` - ID string `json:"id"` - Output Output `json:"output"` - Policies []Policy `json:"policies"` - UpdatedAt time.Time `json:"updated_at"` - Version int64 `json:"version"` - Workflow GrantWorkflow `json:"workflow"` + CreatedAt time.Time `json:"created_at"` + Description string `json:"description"` + GrantKitID string `json:"grant_kit_id"` + GrantKitName string `json:"grant_kit_name"` + ID string `json:"id"` + Output Output `json:"output"` + Policies []Policy `json:"policies"` + UpdatedAt time.Time `json:"updated_at"` + Version int64 `json:"version"` + Workflow *GrantWorkflow `json:"workflow"` } diff --git a/internal/sdk/pkg/models/shared/identity.go b/internal/sdk/pkg/models/shared/identity.go index 7ae3090..02326e9 100755 --- a/internal/sdk/pkg/models/shared/identity.go +++ b/internal/sdk/pkg/models/shared/identity.go @@ -6,7 +6,6 @@ import ( "time" ) -// Identity - Created type Identity struct { AbbeyAccount string `json:"abbey_account"` CreatedAt time.Time `json:"created_at"` diff --git a/internal/sdk/pkg/models/shared/oauth.go b/internal/sdk/pkg/models/shared/oauth.go new file mode 100755 index 0000000..8c4c304 --- /dev/null +++ b/internal/sdk/pkg/models/shared/oauth.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type Oauth struct { + Application *string `json:"application,omitempty"` + CreatedDate *string `json:"created_date,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/oauth2flow.go b/internal/sdk/pkg/models/shared/oauth2flow.go deleted file mode 100755 index 5611dfd..0000000 --- a/internal/sdk/pkg/models/shared/oauth2flow.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package shared - -type Oauth2Flow struct { - CallbackQueryParams []string `json:"callback_query_params,omitempty"` - ConnectionAuthTypeEnum *ConnectionAuthTypeEnum `json:"type,omitempty"` - // Describes how the client should conduct the authorization code exchange. - // - Exchange *Oauth2FlowExchange `json:"exchange,omitempty"` - Pkce *Oauth2FlowPkce `json:"pkce,omitempty"` - QueryParams []KeyValuePair `json:"query_params,omitempty"` - URL string `json:"url"` -} diff --git a/internal/sdk/pkg/models/shared/oauthcreateparams.go b/internal/sdk/pkg/models/shared/oauthcreateparams.go new file mode 100755 index 0000000..1ae5ab5 --- /dev/null +++ b/internal/sdk/pkg/models/shared/oauthcreateparams.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type OAuthCreateParams struct { + Application *string `json:"application,omitempty"` + Code *string `json:"code,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/oauthlisting.go b/internal/sdk/pkg/models/shared/oauthlisting.go new file mode 100755 index 0000000..a00c0fa --- /dev/null +++ b/internal/sdk/pkg/models/shared/oauthlisting.go @@ -0,0 +1,9 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type OauthListing struct { + Items []Oauth `json:"items"` + Next *string `json:"next,omitempty"` + Prev *string `json:"prev,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/organizationgrantkitcount.go b/internal/sdk/pkg/models/shared/organizationgrantkitcount.go new file mode 100755 index 0000000..85a91c5 --- /dev/null +++ b/internal/sdk/pkg/models/shared/organizationgrantkitcount.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type OrganizationGrantKitCount struct { + GrantKitCount int64 `json:"grant_kit_count"` + OrganizationName string `json:"organization_name"` +} diff --git a/internal/sdk/pkg/models/shared/organizationgrantkitcounts.go b/internal/sdk/pkg/models/shared/organizationgrantkitcounts.go new file mode 100755 index 0000000..824ce6a --- /dev/null +++ b/internal/sdk/pkg/models/shared/organizationgrantkitcounts.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type OrganizationGrantKitCounts struct { + Items []OrganizationGrantKitCount `json:"items"` +} diff --git a/internal/sdk/pkg/models/shared/pagerdutyconnectionvalue.go b/internal/sdk/pkg/models/shared/pagerdutyconnectionvalue.go deleted file mode 100755 index b2fb471..0000000 --- a/internal/sdk/pkg/models/shared/pagerdutyconnectionvalue.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package shared - -type PagerdutyConnectionValue struct { - Name *string `json:"name,omitempty"` - Type ConnectionType `json:"type"` - Value PagerdutyConnection `json:"value"` -} diff --git a/internal/sdk/pkg/models/shared/request.go b/internal/sdk/pkg/models/shared/request.go index e7841bc..59f9286 100755 --- a/internal/sdk/pkg/models/shared/request.go +++ b/internal/sdk/pkg/models/shared/request.go @@ -6,7 +6,6 @@ import ( "time" ) -// Request - Created type Request struct { CreatedAt time.Time `json:"created_at"` GrantID string `json:"grant_id"` diff --git a/internal/sdk/pkg/models/shared/requestparams.go b/internal/sdk/pkg/models/shared/requestparams.go index 7494bc6..24c3f79 100755 --- a/internal/sdk/pkg/models/shared/requestparams.go +++ b/internal/sdk/pkg/models/shared/requestparams.go @@ -3,6 +3,7 @@ package shared type RequestParams struct { - GrantKitID string `json:"grant_kit_id"` - Reason string `json:"reason"` + GrantKitID string `json:"grant_kit_id"` + Reason string `json:"reason"` + UserInput *UserInput `json:"user_input,omitempty"` } diff --git a/internal/sdk/pkg/models/shared/resourcerequestcount.go b/internal/sdk/pkg/models/shared/resourcerequestcount.go new file mode 100755 index 0000000..fd3af33 --- /dev/null +++ b/internal/sdk/pkg/models/shared/resourcerequestcount.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type ResourceRequestCount struct { + RequestCount int64 `json:"request_count"` + ResourceName string `json:"resource_name"` +} diff --git a/internal/sdk/pkg/models/shared/resourcerequestcounts.go b/internal/sdk/pkg/models/shared/resourcerequestcounts.go new file mode 100755 index 0000000..d222196 --- /dev/null +++ b/internal/sdk/pkg/models/shared/resourcerequestcounts.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type ResourceRequestCounts struct { + Items []ResourceRequestCount `json:"items"` +} diff --git a/internal/sdk/pkg/models/shared/review.go b/internal/sdk/pkg/models/shared/review.go index 3f6eb75..51369e6 100755 --- a/internal/sdk/pkg/models/shared/review.go +++ b/internal/sdk/pkg/models/shared/review.go @@ -6,7 +6,6 @@ import ( "time" ) -// Review - Success type Review struct { CreatedAt time.Time `json:"created_at"` Grant *Grant `json:"grant,omitempty"` @@ -17,6 +16,7 @@ type Review struct { PullRequest string `json:"pull_request"` Reason string `json:"reason"` RequestID string `json:"request_id"` + RequestReason string `json:"request_reason"` Status ReviewStatus `json:"status"` UpdatedAt time.Time `json:"updated_at"` UserEmail *string `json:"user_email,omitempty"` diff --git a/internal/sdk/pkg/models/shared/samlconnection.go b/internal/sdk/pkg/models/shared/samlconnection.go new file mode 100755 index 0000000..a9a4024 --- /dev/null +++ b/internal/sdk/pkg/models/shared/samlconnection.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type SamlConnection struct { + AcsURL string `json:"acs_url"` + Active bool `json:"active"` + ID string `json:"id"` + IdpCertificate *string `json:"idp_certificate,omitempty"` + IdpEntityID *string `json:"idp_entity_id,omitempty"` + IdpSsoURL *string `json:"idp_sso_url,omitempty"` + Name string `json:"name"` + Provider string `json:"provider"` + SpEntityID string `json:"sp_entity_id"` +} diff --git a/internal/sdk/pkg/models/shared/samlconnectionparams.go b/internal/sdk/pkg/models/shared/samlconnectionparams.go new file mode 100755 index 0000000..7ab9af9 --- /dev/null +++ b/internal/sdk/pkg/models/shared/samlconnectionparams.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type SamlConnectionParams struct { + Domain string `json:"domain"` + IdpCertificate *string `json:"idp_certificate,omitempty"` + IdpEntityID *string `json:"idp_entity_id,omitempty"` + IdpSsoURL *string `json:"idp_sso_url,omitempty"` + Name string `json:"name"` +} diff --git a/internal/sdk/pkg/models/shared/samlconnections.go b/internal/sdk/pkg/models/shared/samlconnections.go new file mode 100755 index 0000000..53e7058 --- /dev/null +++ b/internal/sdk/pkg/models/shared/samlconnections.go @@ -0,0 +1,7 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type SamlConnections struct { + Items []SamlConnection `json:"items"` +} diff --git a/internal/sdk/pkg/models/shared/samlconnectionupdateparams.go b/internal/sdk/pkg/models/shared/samlconnectionupdateparams.go new file mode 100755 index 0000000..6134a7c --- /dev/null +++ b/internal/sdk/pkg/models/shared/samlconnectionupdateparams.go @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type SamlConnectionUpdateParams struct { + Active *bool `json:"active,omitempty"` + Domain *string `json:"domain,omitempty"` + IdpCertificate *string `json:"idp_certificate,omitempty"` + IdpEntityID *string `json:"idp_entity_id,omitempty"` + IdpSsoURL *string `json:"idp_sso_url,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/slackcommand.go b/internal/sdk/pkg/models/shared/slackcommand.go new file mode 100755 index 0000000..d0646ea --- /dev/null +++ b/internal/sdk/pkg/models/shared/slackcommand.go @@ -0,0 +1,19 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type SlackCommand struct { + APIAppID *string `json:"api_app_id,omitempty"` + ChannelID *string `json:"channel_id,omitempty"` + ChannelName *string `json:"channel_name,omitempty"` + Command *string `json:"command,omitempty"` + EnterpriseID *string `json:"enterprise_id,omitempty"` + EnterpriseName *string `json:"enterprise_name,omitempty"` + ResponseURL *string `json:"response_url,omitempty"` + TeamDomain *string `json:"team_domain,omitempty"` + TeamID *string `json:"team_id,omitempty"` + Text *string `json:"text,omitempty"` + Token *string `json:"token,omitempty"` + TriggerID *string `json:"trigger_id,omitempty"` + UserName *string `json:"user_name,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/userapprovalanalytics.go b/internal/sdk/pkg/models/shared/userapprovalanalytics.go new file mode 100755 index 0000000..b9b73f2 --- /dev/null +++ b/internal/sdk/pkg/models/shared/userapprovalanalytics.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type UserApprovalAnalytics struct { + Approvals []UserApprovalCount `json:"approvals"` + Denials []UserApprovalCount `json:"denials"` +} diff --git a/internal/sdk/pkg/models/shared/userapprovalcount.go b/internal/sdk/pkg/models/shared/userapprovalcount.go new file mode 100755 index 0000000..a5e9ebb --- /dev/null +++ b/internal/sdk/pkg/models/shared/userapprovalcount.go @@ -0,0 +1,8 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +type UserApprovalCount struct { + PrimaryEmailAddress string `json:"primary_email_address"` + RequestCount int64 `json:"request_count"` +} diff --git a/internal/sdk/pkg/models/shared/userinput.go b/internal/sdk/pkg/models/shared/userinput.go new file mode 100755 index 0000000..f5b1c2d --- /dev/null +++ b/internal/sdk/pkg/models/shared/userinput.go @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type UserInput struct { + ExpireAt *time.Time `json:"expire_at,omitempty"` + ExpireIn *string `json:"expire_in,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosdirectorydata.go b/internal/sdk/pkg/models/shared/workosdirectorydata.go new file mode 100755 index 0000000..940d59c --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosdirectorydata.go @@ -0,0 +1,26 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSDirectoryDataDomains struct { + Domain *string `json:"domain,omitempty"` + ID *string `json:"id,omitempty"` + Object *string `json:"object,omitempty"` +} + +type WorkOSDirectoryData struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + Domains []WorkOSDirectoryDataDomains `json:"domains,omitempty"` + ExternalKey *string `json:"external_key,omitempty"` + ID *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Object *string `json:"object,omitempty"` + OrganizationID *string `json:"organization_id,omitempty"` + State *string `json:"state,omitempty"` + Type *string `json:"type,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosdirectoryevent.go b/internal/sdk/pkg/models/shared/workosdirectoryevent.go new file mode 100755 index 0000000..a57cb63 --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosdirectoryevent.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSDirectoryEvent struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + Data *WorkOSDirectoryData `json:"data,omitempty"` + Event *string `json:"event,omitempty"` + ID *string `json:"id,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosgroup.go b/internal/sdk/pkg/models/shared/workosgroup.go new file mode 100755 index 0000000..3612b38 --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosgroup.go @@ -0,0 +1,26 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSGroupPreviousAttributes struct { +} + +type WorkOSGroupRawAttributes struct { +} + +type WorkOSGroup struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + DirectoryID *string `json:"directory_id,omitempty"` + ID *string `json:"id,omitempty"` + IdpID *string `json:"idp_id,omitempty"` + Name *string `json:"name,omitempty"` + Object *string `json:"object,omitempty"` + OrganizationID *string `json:"organization_id,omitempty"` + PreviousAttributes *WorkOSGroupPreviousAttributes `json:"previous_attributes,omitempty"` + RawAttributes *WorkOSGroupRawAttributes `json:"raw_attributes,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosgroupdata.go b/internal/sdk/pkg/models/shared/workosgroupdata.go new file mode 100755 index 0000000..6e9003e --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosgroupdata.go @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSGroupDataPreviousAttributes struct { +} + +type WorkOSGroupDataRawAttributes struct { +} + +type WorkOSGroupData struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + DirectoryID *string `json:"directory_id,omitempty"` + Group *WorkOSGroup `json:"group,omitempty"` + ID *string `json:"id,omitempty"` + IdpID *string `json:"idp_id,omitempty"` + Name *string `json:"name,omitempty"` + Object *string `json:"object,omitempty"` + OrganizationID *string `json:"organization_id,omitempty"` + PreviousAttributes *WorkOSGroupDataPreviousAttributes `json:"previous_attributes,omitempty"` + RawAttributes *WorkOSGroupDataRawAttributes `json:"raw_attributes,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + User *WorkOSUserData `json:"user,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosgroupevent.go b/internal/sdk/pkg/models/shared/workosgroupevent.go new file mode 100755 index 0000000..29b8be2 --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosgroupevent.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSGroupEvent struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + Data *WorkOSGroupData `json:"data,omitempty"` + Event *string `json:"event,omitempty"` + ID *string `json:"id,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosuserdata.go b/internal/sdk/pkg/models/shared/workosuserdata.go new file mode 100755 index 0000000..ef6f68e --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosuserdata.go @@ -0,0 +1,41 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSUserDataCustomAttributes struct { +} + +type WorkOSUserDataEmails struct { + Primary *bool `json:"primary,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +type WorkOSUserDataPreviousAttributes struct { +} + +type WorkOSUserDataRawAttributes struct { +} + +type WorkOSUserData struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + CustomAttributes *WorkOSUserDataCustomAttributes `json:"custom_attributes,omitempty"` + DirectoryID *string `json:"directory_id,omitempty"` + Emails []WorkOSUserDataEmails `json:"emails,omitempty"` + FirstName *string `json:"first_name,omitempty"` + ID *string `json:"id,omitempty"` + IdpID *string `json:"idp_id,omitempty"` + JobTitle *string `json:"job_title,omitempty"` + LastName *string `json:"last_name,omitempty"` + Object *string `json:"object,omitempty"` + OrganizationID *string `json:"organization_id,omitempty"` + PreviousAttributes *WorkOSUserDataPreviousAttributes `json:"previous_attributes,omitempty"` + RawAttributes *WorkOSUserDataRawAttributes `json:"raw_attributes,omitempty"` + State *string `json:"state,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/internal/sdk/pkg/models/shared/workosuserevent.go b/internal/sdk/pkg/models/shared/workosuserevent.go new file mode 100755 index 0000000..416a63d --- /dev/null +++ b/internal/sdk/pkg/models/shared/workosuserevent.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package shared + +import ( + "time" +) + +type WorkOSUserEvent struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + Data *WorkOSUserData `json:"data,omitempty"` + Event *string `json:"event,omitempty"` + ID *string `json:"id,omitempty"` +} diff --git a/internal/sdk/pkg/types/datetime.go b/internal/sdk/pkg/types/datetime.go index 0529b25..5bfcff5 100755 --- a/internal/sdk/pkg/types/datetime.go +++ b/internal/sdk/pkg/types/datetime.go @@ -7,7 +7,7 @@ import "time" // MustTimeFromString returns a time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. // Avoid using this function in production code. func MustTimeFromString(str string) time.Time { - t, err := time.Parse(time.RFC3339, str) + t, err := time.Parse(time.RFC3339Nano, str) if err != nil { panic(err) } diff --git a/internal/sdk/pkg/utils/form.go b/internal/sdk/pkg/utils/form.go index 5e12f27..302fe09 100755 --- a/internal/sdk/pkg/utils/form.go +++ b/internal/sdk/pkg/utils/form.go @@ -17,10 +17,11 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue formValues := url.Values{} + if isNil(objType, objValue) { + return formValues + } + if objType.Kind() == reflect.Pointer { - if objValue.IsNil() { - return formValues - } objType = objType.Elem() objValue = objValue.Elem() } @@ -43,11 +44,11 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue fieldType := objType.Field(i) valType := objValue.Field(i) - if valType.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } + if isNil(fieldType.Type, valType) { + continue + } + if valType.Kind() == reflect.Pointer { valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/headers.go b/internal/sdk/pkg/utils/headers.go index d8ca9b1..0837022 100755 --- a/internal/sdk/pkg/utils/headers.go +++ b/internal/sdk/pkg/utils/headers.go @@ -31,10 +31,11 @@ func PopulateHeaders(ctx context.Context, req *http.Request, headers interface{} } func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { + if isNil(objType, objValue) { + return "" + } + if objType.Kind() == reflect.Pointer { - if objValue.IsNil() { - return "" - } objType = objType.Elem() objValue = objValue.Elem() } @@ -47,10 +48,11 @@ func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) fieldType := objType.Field(i) valType := objValue.Field(i) + if isNil(fieldType.Type, valType) { + continue + } + if fieldType.Type.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/pathparams.go b/internal/sdk/pkg/utils/pathparams.go index c2fd728..1e0dcac 100755 --- a/internal/sdk/pkg/utils/pathparams.go +++ b/internal/sdk/pkg/utils/pathparams.go @@ -61,10 +61,11 @@ func GenerateURL(ctx context.Context, serverURL, path string, pathParams interfa func getSimplePathParams(ctx context.Context, parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { pathParams := make(map[string]string) + if isNil(objType, objValue) { + return nil + } + if objType.Kind() == reflect.Ptr { - if objValue.IsNil() { - return nil - } objType = objType.Elem() objValue = objValue.Elem() } @@ -104,10 +105,11 @@ func getSimplePathParams(ctx context.Context, parentName string, objType reflect continue } + if isNil(fieldType.Type, valType) { + continue + } + if fieldType.Type.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/queryparams.go b/internal/sdk/pkg/utils/queryparams.go index 87ecef8..0e94bce 100755 --- a/internal/sdk/pkg/utils/queryparams.go +++ b/internal/sdk/pkg/utils/queryparams.go @@ -76,15 +76,13 @@ func PopulateQueryParams(ctx context.Context, req *http.Request, queryParams int } func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { + if isNil(objType, objValue) { + return nil, nil + } + if objType.Kind() == reflect.Pointer { - if objValue.IsNil() { - return nil, nil - } objValue = objValue.Elem() } - if objValue.Interface() == nil { - return nil, nil - } values := map[string]string{} @@ -103,10 +101,11 @@ func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue refl func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { values := url.Values{} + if isNil(objType, objValue) { + return values + } + if objType.Kind() == reflect.Pointer { - if objValue.IsNil() { - return values - } objType = objType.Elem() objValue = objValue.Elem() } @@ -117,10 +116,11 @@ func populateDeepObjectParams(req *http.Request, tag *paramTag, objType reflect. fieldType := objType.Field(i) valType := objValue.Field(i) + if isNil(fieldType.Type, valType) { + continue + } + if fieldType.Type.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/requestbody.go b/internal/sdk/pkg/utils/requestbody.go index 5c1d263..d9fcbda 100755 --- a/internal/sdk/pkg/utils/requestbody.go +++ b/internal/sdk/pkg/utils/requestbody.go @@ -26,15 +26,15 @@ var ( urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) ) -func SerializeRequestBody(ctx context.Context, request interface{}, requestFieldName string, serializationMethod string) (*bytes.Buffer, string, error) { +func SerializeRequestBody(ctx context.Context, request interface{}, requestFieldName string, serializationMethod string) (io.Reader, string, error) { requestStructType := reflect.TypeOf(request) requestValType := reflect.ValueOf(request) - if requestStructType.Kind() == reflect.Pointer { - if requestValType.IsNil() { - return nil, "", nil - } + if isNil(requestStructType, requestValType) { + return nil, "", nil + } + if requestStructType.Kind() == reflect.Pointer { requestStructType = requestStructType.Elem() requestValType = requestValType.Elem() } @@ -50,7 +50,7 @@ func SerializeRequestBody(ctx context.Context, request interface{}, requestField if tag != nil { // request object (non-flattened) requestVal := requestValType.FieldByName(requestFieldName) - if requestField.Type.Kind() == reflect.Pointer && requestVal.IsNil() { + if isNil(requestField.Type, requestVal) { return nil, "", nil } @@ -116,11 +116,11 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { fieldType := field.Type valType := requestValType.Field(i) - if fieldType.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } + if isNil(fieldType, valType) { + continue + } + if fieldType.Kind() == reflect.Pointer { fieldType = fieldType.Elem() valType = valType.Elem() } @@ -231,11 +231,11 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { fieldType := field.Type valType := requestValType.Field(i) - if fieldType.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } + if isNil(fieldType, valType) { + continue + } + if fieldType.Kind() == reflect.Pointer { fieldType = fieldType.Elem() valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/security.go b/internal/sdk/pkg/utils/security.go index ec837d7..675cd57 100755 --- a/internal/sdk/pkg/utils/security.go +++ b/internal/sdk/pkg/utils/security.go @@ -69,11 +69,11 @@ func parseSecurityStruct(c HTTPClient, security interface{}) *SecurityClient { securityStructType := reflect.TypeOf(security) securityValType := reflect.ValueOf(security) - if securityStructType.Kind() == reflect.Ptr { - if securityValType.IsNil() { - return nil - } + if isNil(securityStructType, securityValType) { + return nil + } + if securityStructType.Kind() == reflect.Ptr { securityStructType = securityStructType.Elem() securityValType = securityValType.Elem() } @@ -86,11 +86,11 @@ func parseSecurityStruct(c HTTPClient, security interface{}) *SecurityClient { kind := valType.Kind() - if fieldType.Type.Kind() == reflect.Pointer { - if valType.IsNil() { - continue - } + if isNil(fieldType.Type, valType) { + continue + } + if fieldType.Type.Kind() == reflect.Pointer { kind = valType.Elem().Kind() } @@ -117,11 +117,11 @@ func parseSecurityOption(c HTTPClient, option interface{}) *SecurityClient { optionStructType := reflect.TypeOf(option) optionValType := reflect.ValueOf(option) - if optionStructType.Kind() == reflect.Ptr { - if optionValType.IsNil() { - return nil - } + if isNil(optionStructType, optionValType) { + return nil + } + if optionStructType.Kind() == reflect.Ptr { optionStructType = optionStructType.Elem() optionValType = optionValType.Elem() } @@ -145,11 +145,11 @@ func parseSecurityScheme(client *SecurityClient, schemeTag *securityTag, scheme schemeType := reflect.TypeOf(scheme) schemeVal := reflect.ValueOf(scheme) - if schemeType.Kind() == reflect.Ptr { - if schemeVal.IsNil() { - return - } + if isNil(schemeType, schemeVal) { + return + } + if schemeType.Kind() == reflect.Ptr { schemeType = schemeType.Elem() schemeVal = schemeVal.Elem() } @@ -164,11 +164,11 @@ func parseSecurityScheme(client *SecurityClient, schemeTag *securityTag, scheme fieldType := schemeType.Field(i) valType := schemeVal.Field(i) - if fieldType.Type.Kind() == reflect.Ptr { - if valType.IsNil() { - continue - } + if isNil(fieldType.Type, valType) { + continue + } + if fieldType.Type.Kind() == reflect.Ptr { valType = valType.Elem() } diff --git a/internal/sdk/pkg/utils/utils.go b/internal/sdk/pkg/utils/utils.go index fc65050..ec3dbce 100755 --- a/internal/sdk/pkg/utils/utils.go +++ b/internal/sdk/pkg/utils/utils.go @@ -45,6 +45,10 @@ func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}) error { } func ReplaceParameters(stringWithParams string, params map[string]string) string { + if len(params) == 0 { + return stringWithParams + } + return paramRegex.ReplaceAllStringFunc(stringWithParams, func(match string) string { match = match[1 : len(match)-1] return params[match] @@ -150,3 +154,11 @@ func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, p return valType } + +func isNil(typ reflect.Type, val reflect.Value) bool { + if typ.Kind() == reflect.Ptr || typ.Kind() == reflect.Map || typ.Kind() == reflect.Slice || typ.Kind() == reflect.Interface { + return val.IsNil() + } + + return false +} diff --git a/internal/sdk/requests.go b/internal/sdk/requests.go index b5509e8..7dc168b 100755 --- a/internal/sdk/requests.go +++ b/internal/sdk/requests.go @@ -44,12 +44,15 @@ func (s *requests) CancelRequestByID(ctx context.Context, request operations.Can return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -67,6 +70,7 @@ func (s *requests) CancelRequestByID(ctx context.Context, request operations.Can if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -83,7 +87,7 @@ func (s *requests) CancelRequestByID(ctx context.Context, request operations.Can case utils.MatchContentType(contentType, `application/json`): var out *shared.Request if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Request = out @@ -103,7 +107,7 @@ func (s *requests) CancelRequestByID(ctx context.Context, request operations.Can case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -133,12 +137,15 @@ func (s *requests) CreateRequest(ctx context.Context, request shared.RequestPara return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "POST", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -156,6 +163,7 @@ func (s *requests) CreateRequest(ctx context.Context, request shared.RequestPara if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -172,7 +180,7 @@ func (s *requests) CreateRequest(ctx context.Context, request shared.RequestPara case utils.MatchContentType(contentType, `application/json`): var out *shared.Request if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Request = out @@ -190,7 +198,7 @@ func (s *requests) CreateRequest(ctx context.Context, request shared.RequestPara case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -214,7 +222,7 @@ func (s *requests) GetRequestByID(ctx context.Context, request operations.GetReq return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -246,7 +254,7 @@ func (s *requests) GetRequestByID(ctx context.Context, request operations.GetReq case utils.MatchContentType(contentType, `application/json`): var out *shared.Request if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Request = out @@ -262,7 +270,7 @@ func (s *requests) GetRequestByID(ctx context.Context, request operations.GetReq case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -285,7 +293,7 @@ func (s *requests) ListRequests(ctx context.Context) (*operations.ListRequestsRe return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -317,7 +325,7 @@ func (s *requests) ListRequests(ctx context.Context) (*operations.ListRequestsRe case utils.MatchContentType(contentType, `application/json`): var out []shared.Request if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Requests = out @@ -331,7 +339,7 @@ func (s *requests) ListRequests(ctx context.Context) (*operations.ListRequestsRe case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/reviews.go b/internal/sdk/reviews.go index 38bd6e2..4f8e508 100755 --- a/internal/sdk/reviews.go +++ b/internal/sdk/reviews.go @@ -42,7 +42,7 @@ func (s *reviews) ListReviews(ctx context.Context) (*operations.ListReviewsRespo return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -74,7 +74,7 @@ func (s *reviews) ListReviews(ctx context.Context) (*operations.ListReviewsRespo case utils.MatchContentType(contentType, `application/json`): var out []shared.Review if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Reviews = out @@ -88,7 +88,7 @@ func (s *reviews) ListReviews(ctx context.Context) (*operations.ListReviewsRespo case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -115,12 +115,15 @@ func (s *reviews) ApproveReview(ctx context.Context, request operations.ApproveR return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -138,6 +141,7 @@ func (s *reviews) ApproveReview(ctx context.Context, request operations.ApproveR if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -154,7 +158,7 @@ func (s *reviews) ApproveReview(ctx context.Context, request operations.ApproveR case utils.MatchContentType(contentType, `application/json`): var out *shared.Review if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Review = out @@ -174,7 +178,7 @@ func (s *reviews) ApproveReview(ctx context.Context, request operations.ApproveR case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -201,12 +205,15 @@ func (s *reviews) DenyReview(ctx context.Context, request operations.DenyReviewR return nil, fmt.Errorf("request body is required") } - req, err := http.NewRequestWithContext(ctx, "PUT", url, bodyReader) + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) req.Header.Set("Content-Type", reqContentType) @@ -224,6 +231,7 @@ func (s *reviews) DenyReview(ctx context.Context, request operations.DenyReviewR if err != nil { return nil, fmt.Errorf("error reading response body: %w", err) } + httpRes.Request.Body = io.NopCloser(debugBody) httpRes.Body.Close() httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) @@ -240,7 +248,7 @@ func (s *reviews) DenyReview(ctx context.Context, request operations.DenyReviewR case utils.MatchContentType(contentType, `application/json`): var out *shared.Review if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Review = out @@ -260,7 +268,7 @@ func (s *reviews) DenyReview(ctx context.Context, request operations.DenyReviewR case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out @@ -284,7 +292,7 @@ func (s *reviews) GetReviewByID(ctx context.Context, request operations.GetRevie return nil, fmt.Errorf("error creating request: %w", err) } req.Header.Set("Accept", "application/json") - req.Header.Set("user-agent", fmt.Sprintf("speakeasy-sdk/%s %s %s %s", s.sdkConfiguration.Language, s.sdkConfiguration.SDKVersion, s.sdkConfiguration.GenVersion, s.sdkConfiguration.OpenAPIDocVersion)) + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) client := s.sdkConfiguration.SecurityClient @@ -316,7 +324,7 @@ func (s *reviews) GetReviewByID(ctx context.Context, request operations.GetRevie case utils.MatchContentType(contentType, `application/json`): var out *shared.Review if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Review = out @@ -332,7 +340,7 @@ func (s *reviews) GetReviewByID(ctx context.Context, request operations.GetRevie case utils.MatchContentType(contentType, `application/json`): var out *shared.Error if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { - return nil, err + return res, err } res.Error = out diff --git a/internal/sdk/samlconnections.go b/internal/sdk/samlconnections.go new file mode 100755 index 0000000..2cf6bef --- /dev/null +++ b/internal/sdk/samlconnections.go @@ -0,0 +1,399 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +// samlConnections - SAML Connections setup a SAML / SSO connection with an Identity Provider +// +// https://docs.abbey.io +type samlConnections struct { + sdkConfiguration sdkConfiguration +} + +func newSAMLConnections(sdkConfig sdkConfiguration) *samlConnections { + return &samlConnections{ + sdkConfiguration: sdkConfig, + } +} + +// CreateSamlConnection - Create a new SAML connection +// Creates a new SAML connection +func (s *samlConnections) CreateSamlConnection(ctx context.Context, request shared.SamlConnectionParams) (*operations.CreateSamlConnectionResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/samlConnection" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.CreateSamlConnectionResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.SamlConnection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.SamlConnection = out + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 409: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// DeleteSamlConnectionByID - Deletes a SAML connection by its ID +// Deletes a SAML connection by its ID +func (s *samlConnections) DeleteSamlConnectionByID(ctx context.Context, request operations.DeleteSamlConnectionByIDRequest) (*operations.DeleteSamlConnectionByIDResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/samlConnection/{saml_connection_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.DeleteSamlConnectionByIDResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// GetSamlConnectionByID - Fetches a SAML connection by its ID +// Checks whether a user has a SAML connection and then hydrates the connection from Clerk +func (s *samlConnections) GetSamlConnectionByID(ctx context.Context, request operations.GetSamlConnectionByIDRequest) (*operations.GetSamlConnectionByIDResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/samlConnection/{saml_connection_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.GetSamlConnectionByIDResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.SamlConnection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.SamlConnection = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// ListSamlConnections - List SAML Connections +// Returns a list of SAML connections. +// The connections are scoped by the current user and returned from Clerk +func (s *samlConnections) ListSamlConnections(ctx context.Context) (*operations.ListSamlConnectionsResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/samlConnection" + + req, err := http.NewRequestWithContext(ctx, "GET", url, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.ListSamlConnectionsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.SamlConnections + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.SamlConnections = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// UpdateSamlConnectionByID - Updates a SAML connection by its ID +// Checks whether a user owns a SAML connection and then updates the SAML connection +func (s *samlConnections) UpdateSamlConnectionByID(ctx context.Context, request operations.UpdateSamlConnectionByIDRequest) (*operations.UpdateSamlConnectionByIDResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url, err := utils.GenerateURL(ctx, baseURL, "/samlConnection/{saml_connection_id}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "SamlConnectionUpdateParams", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "PUT", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.UpdateSamlConnectionByIDResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.SamlConnection + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.SamlConnection = out + } + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 404: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 3d4e673..12f4d07 100755 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -56,6 +56,7 @@ type sdkConfiguration struct { OpenAPIDocVersion string SDKVersion string GenVersion string + UserAgent string } func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { @@ -77,6 +78,8 @@ type SDK struct { // // https://docs.abbey.io/product/managing-api-keys APIKeys *apiKeys + // Analytics - Analytics endpoints for use in the console + Analytics *analytics // ConnectionSpecs - Connection Specs are the templates for creating connections. // They are used to validate connection parameters and to provide a UI for creating connections. // @@ -88,7 +91,8 @@ type SDK struct { Connections *connections // Demo - Abbey Demo // https://docs.abbey.io/getting-started/quickstart - Demo *demo + Demo *demo + DirectorySync *directorySync // GrantKits - Grant Kits are what you configure in code to control and automatically right-size permissions for resources. // A Grant Kit has 3 components: // @@ -111,6 +115,10 @@ type SDK struct { // // https://docs.abbey.io Identities *identities + // Oauth - Abbey OAuth + // https://docs.abbey.io + Oauth *oauth + Oauths *oauths // Requests - Requests are Access Requests that users make to get access to a resource. // // https://docs.abbey.io/getting-started/concepts#access-requests @@ -121,6 +129,13 @@ type SDK struct { // // https://docs.abbey.io/product/approving-or-denying-access-requests Reviews *reviews + // SAMLConnections - SAML Connections setup a SAML / SSO connection with an Identity Provider + // + // https://docs.abbey.io + SAMLConnections *samlConnections + SlackCommand *slackCommand + // WorkOS - WorkOS Webhook endpoints + WorkOS *workOS sdkConfiguration sdkConfiguration } @@ -177,8 +192,9 @@ func New(opts ...SDKOption) *SDK { sdkConfiguration: sdkConfiguration{ Language: "terraform", OpenAPIDocVersion: "v1", - SDKVersion: "2.2.1", - GenVersion: "2.75.1", + SDKVersion: "2.14.2", + GenVersion: "2.150.0", + UserAgent: "speakeasy-sdk/terraform 2.14.2 2.150.0 v1 abbey", }, } for _, opt := range opts { @@ -199,21 +215,35 @@ func New(opts ...SDKOption) *SDK { sdk.APIKeys = newAPIKeys(sdk.sdkConfiguration) + sdk.Analytics = newAnalytics(sdk.sdkConfiguration) + sdk.ConnectionSpecs = newConnectionSpecs(sdk.sdkConfiguration) sdk.Connections = newConnections(sdk.sdkConfiguration) sdk.Demo = newDemo(sdk.sdkConfiguration) + sdk.DirectorySync = newDirectorySync(sdk.sdkConfiguration) + sdk.GrantKits = newGrantKits(sdk.sdkConfiguration) sdk.Grants = newGrants(sdk.sdkConfiguration) sdk.Identities = newIdentities(sdk.sdkConfiguration) + sdk.Oauth = newOauth(sdk.sdkConfiguration) + + sdk.Oauths = newOauths(sdk.sdkConfiguration) + sdk.Requests = newRequests(sdk.sdkConfiguration) sdk.Reviews = newReviews(sdk.sdkConfiguration) + sdk.SAMLConnections = newSAMLConnections(sdk.sdkConfiguration) + + sdk.SlackCommand = newSlackCommand(sdk.sdkConfiguration) + + sdk.WorkOS = newWorkOS(sdk.sdkConfiguration) + return sdk } diff --git a/internal/sdk/slackcommand.go b/internal/sdk/slackcommand.go new file mode 100755 index 0000000..bc4ca14 --- /dev/null +++ b/internal/sdk/slackcommand.go @@ -0,0 +1,109 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +type slackCommand struct { + sdkConfiguration sdkConfiguration +} + +func newSlackCommand(sdkConfig sdkConfiguration) *slackCommand { + return &slackCommand{ + sdkConfiguration: sdkConfig, + } +} + +// SlackCommand - Receive a slash command from Slack +// Receives slash commands initiated from the Abbey Slack App +func (s *slackCommand) SlackCommand(ctx context.Context, request shared.SlackCommand) (*operations.SlackCommandResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/slackcommands" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.SlackCommandResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.OauthListing + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.OauthListing = out + } + case httpRes.StatusCode == 201: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/sdk/workos.go b/internal/sdk/workos.go new file mode 100755 index 0000000..049cbce --- /dev/null +++ b/internal/sdk/workos.go @@ -0,0 +1,252 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package sdk + +import ( + "abbey/v2/internal/sdk/pkg/models/operations" + "abbey/v2/internal/sdk/pkg/models/shared" + "abbey/v2/internal/sdk/pkg/utils" + "bytes" + "context" + "fmt" + "io" + "net/http" + "strings" +) + +// workOS - WorkOS Webhook endpoints +type workOS struct { + sdkConfiguration sdkConfiguration +} + +func newWorkOS(sdkConfig sdkConfiguration) *workOS { + return &workOS{ + sdkConfiguration: sdkConfig, + } +} + +// WorkOSDirectoriesWebhook - Receive Directories Webhook +// Receives Directories Webhook Update +func (s *workOS) WorkOSDirectoriesWebhook(ctx context.Context, request shared.WorkOSDirectoryEvent) (*operations.WorkOSDirectoriesWebhookResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/webhooks/workos/directories" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.WorkOSDirectoriesWebhookResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// WorkOSGroupsWebhook - Receive Groups Webhook +// Receives Groups Webhook Update +func (s *workOS) WorkOSGroupsWebhook(ctx context.Context, request shared.WorkOSGroupEvent) (*operations.WorkOSGroupsWebhookResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/webhooks/workos/groups" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.WorkOSGroupsWebhookResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + fallthrough + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} + +// WorkOSUsersWebhook - Receive Users Webhook +// Receives Users Webhook Update +func (s *workOS) WorkOSUsersWebhook(ctx context.Context, request shared.WorkOSUserEvent) (*operations.WorkOSUsersWebhookResponse, error) { + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + url := strings.TrimSuffix(baseURL, "/") + "/webhooks/workos/users" + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, "Request", "json") + if err != nil { + return nil, fmt.Errorf("error serializing request body: %w", err) + } + if bodyReader == nil { + return nil, fmt.Errorf("request body is required") + } + + debugBody := bytes.NewBuffer([]byte{}) + debugReader := io.TeeReader(bodyReader, debugBody) + + req, err := http.NewRequestWithContext(ctx, "POST", url, debugReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) + + req.Header.Set("Content-Type", reqContentType) + + client := s.sdkConfiguration.SecurityClient + + httpRes, err := client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %w", err) + } + if httpRes == nil { + return nil, fmt.Errorf("error sending request: no response") + } + + rawBody, err := io.ReadAll(httpRes.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + httpRes.Request.Body = io.NopCloser(debugBody) + httpRes.Body.Close() + httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + contentType := httpRes.Header.Get("Content-Type") + + res := &operations.WorkOSUsersWebhookResponse{ + StatusCode: httpRes.StatusCode, + ContentType: contentType, + RawResponse: httpRes, + } + switch { + case httpRes.StatusCode == 200: + fallthrough + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 429: + fallthrough + default: + switch { + case utils.MatchContentType(contentType, `application/json`): + var out *shared.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out); err != nil { + return res, err + } + + res.Error = out + } + } + + return res, nil +} diff --git a/internal/validators/ExactlyOneChild.go b/internal/validators/ExactlyOneChild.go index 839ef01..5741558 100755 --- a/internal/validators/ExactlyOneChild.go +++ b/internal/validators/ExactlyOneChild.go @@ -15,6 +15,10 @@ type exactlyOneChild struct { } func (validator exactlyOneChild) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { + // Only validate the attribute configuration value if it is known. + if req.ConfigValue.IsNull() || req.ConfigValue.IsUnknown() { + return + } defined := make(map[string]bool) count := 0 for key, attr := range req.ConfigValue.Attributes() { diff --git a/internal/validators/RFC3339Validator.go b/internal/validators/RFC3339Validator.go index 42c90dc..ad3d715 100755 --- a/internal/validators/RFC3339Validator.go +++ b/internal/validators/RFC3339Validator.go @@ -4,15 +4,15 @@ package validators import ( "context" + "time" + "github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag" "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "time" ) var _ validator.String = RFC3339TimeValidator{} -type RFC3339TimeValidator struct { -} +type RFC3339TimeValidator struct{} func (validator RFC3339TimeValidator) Description(ctx context.Context) string { return "value must be a string in RFC3339 format" @@ -28,7 +28,7 @@ func (validator RFC3339TimeValidator) ValidateString(ctx context.Context, req va return } - if _, err := time.Parse(time.RFC3339, req.ConfigValue.ValueString()); err != nil { + if _, err := time.Parse(time.RFC3339Nano, req.ConfigValue.ValueString()); err != nil { resp.Diagnostics.Append(validatordiag.InvalidAttributeTypeDiagnostic( req.Path, validator.MarkdownDescription(ctx), @@ -42,7 +42,7 @@ func (validator RFC3339TimeValidator) ValidateString(ctx context.Context, req va // attribute value: // // - Is a String. -// - Is in RFC3339 Format. +// - Is in RFC3339Nano Format. // // Null (unconfigured) and unknown (known after apply) values are skipped. func IsRFC3339() validator.String {