diff --git a/.gitignore b/.gitignore index 1a5a0a1..068e5a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.env +.env.local **/.speakeasy/temp/ **/.speakeasy/logs/ .terraform diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 3739f95..7b3fdbe 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,13 +1,13 @@ lockVersion: 2.0.0 id: 5a857039-7f4b-42d5-86fd-449767242ed2 management: - docChecksum: e4bc94f22669b9c9d0ff0b0ae1d8332b + docChecksum: 5d2693c2df40639274e0cf23ad533308 docVersion: 1.0.0 - speakeasyVersion: 1.611.0 - generationVersion: 2.694.1 - releaseVersion: 0.25.16 - configChecksum: 0326eb73b22ea6e1407f82c11218b82e - repoURL: https://github.com/epilot-dev/terraform-provider-epilot-product.git + speakeasyVersion: 1.642.2 + generationVersion: 2.731.6 + releaseVersion: 0.26.0 + configChecksum: 686437ee57ce33eb2da83bcf59ce8aac + repoURL: https://github.com/epilot-dev/terraform-provider-epilot-portal.git repoSubDirectory: . published: true features: @@ -21,31 +21,16 @@ features: unions: 2.85.0 terraform: additionalDependencies: 0.1.0 - additionalProperties: 0.1.2 - constsAndDefaults: 0.2.1 - core: 3.44.1 - deepObjectParams: 0.1.0 - deprecations: 2.82.0 - globalSecurity: 2.82.0 + constsAndDefaults: 0.3.0 + core: 3.46.3 + globalSecurity: 2.82.1 globalServerURLs: 2.83.0 - methodSecurity: 2.82.2 - nullables: 0.0.0 retries: 2.81.4 - typeOverrides: 2.81.1 - unions: 2.81.17 + unions: 2.82.2 generatedFiles: - .gitattributes - USAGE.md - - examples/README.md - - examples/data-sources/epilot-portal_portal_config/data-source.tf - - examples/data-sources/epilot-portal_portal_page/data-source.tf - examples/provider/provider.tf - - examples/resources/epilot-portal_portal_config/import-by-string-id.tf - - examples/resources/epilot-portal_portal_config/import.sh - - examples/resources/epilot-portal_portal_config/resource.tf - - examples/resources/epilot-portal_portal_page/import-by-string-id.tf - - examples/resources/epilot-portal_portal_page/import.sh - - examples/resources/epilot-portal_portal_page/resource.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -60,14 +45,6 @@ generatedFiles: - internal/planmodifiers/setplanmodifier/suppress_diff.go - internal/planmodifiers/stringplanmodifier/suppress_diff.go - internal/planmodifiers/utils/state_check.go - - internal/provider/portalconfig_data_source.go - - internal/provider/portalconfig_data_source_sdk.go - - internal/provider/portalconfig_resource.go - - internal/provider/portalconfig_resource_sdk.go - - internal/provider/portalpage_data_source.go - - internal/provider/portalpage_data_source_sdk.go - - internal/provider/portalpage_resource.go - - internal/provider/portalpage_resource_sdk.go - internal/provider/provider.go - internal/provider/reflect/diags.go - internal/provider/reflect/doc.go @@ -86,36 +63,10 @@ generatedFiles: - internal/provider/typeconvert/date.go - internal/provider/typeconvert/datetime.go - internal/provider/typeconvert/int.go - - internal/provider/types/admin_user.go - - internal/provider/types/allowed_file_extensions.go - - internal/provider/types/block.go - - internal/provider/types/block_props.go - - internal/provider/types/email_templates.go - - internal/provider/types/entity_actions.go - - internal/provider/types/extension_config.go - - internal/provider/types/extension_hook_config.go - - internal/provider/types/image_uri.go - - internal/provider/types/portal_config_v3_org_settings.go - - internal/provider/types/portal_config_v3_triggered_journeys.go - - internal/provider/types/upsert_portal_config_v3_action_label.go - - internal/provider/types/upsert_portal_config_v3_advanced_mfa.go - - internal/provider/types/upsert_portal_config_v3_auth_settings.go - - internal/provider/types/upsert_portal_config_v3_cognito_details.go - - internal/provider/types/upsert_portal_config_v3_contract_selector_config.go - - internal/provider/types/upsert_portal_config_v3_default_user_to_notify.go - - internal/provider/types/upsert_portal_config_v3_entity_identifiers.go - - internal/provider/types/upsert_portal_config_v3_feature_settings.go - - internal/provider/types/upsert_portal_config_v3_images.go - - internal/provider/types/upsert_portal_config_v3_password_policy.go - - internal/provider/types/upsert_portal_config_v3_type.go - internal/provider/utils.go - internal/sdk/.gitattributes - - internal/sdk/activity.go - - internal/sdk/balance.go + - internal/sdk/assignments.go - internal/sdk/docs/models/operations/option.md - - internal/sdk/ecp.go - - internal/sdk/ecpadmin.go - - internal/sdk/internal.go - internal/sdk/internal/config/sdkconfiguration.go - internal/sdk/internal/hooks/hooks.go - internal/sdk/internal/utils/contenttype.go @@ -129,207 +80,44 @@ generatedFiles: - internal/sdk/internal/utils/retries.go - internal/sdk/internal/utils/security.go - internal/sdk/internal/utils/utils.go - - internal/sdk/login.go - internal/sdk/models/errors/sdkerror.go - - internal/sdk/models/operations/addcontractbyidentifiers.go - - internal/sdk/models/operations/cantriggerportalflow.go - - internal/sdk/models/operations/checkcontactexists.go - - internal/sdk/models/operations/configuredistribution.go - - internal/sdk/models/operations/confirmuser.go - - internal/sdk/models/operations/confirmuserwithuserid.go - - internal/sdk/models/operations/createcustomentityactivity.go - - internal/sdk/models/operations/createportalconfig.go - - internal/sdk/models/operations/createportalpage.go - - internal/sdk/models/operations/createportalpageblock.go - - internal/sdk/models/operations/createuser.go - - internal/sdk/models/operations/deleteentityfile.go - - internal/sdk/models/operations/deleteportal.go - - internal/sdk/models/operations/deleteportalconfig.go - - internal/sdk/models/operations/deleteportalpage.go - - internal/sdk/models/operations/deleteportalpageblock.go - - internal/sdk/models/operations/deleteportaluser.go - - internal/sdk/models/operations/deregistermloginuser.go - - internal/sdk/models/operations/extrapermissionattributes.go - - internal/sdk/models/operations/fetchportalusersbyrelatedentity.go - - internal/sdk/models/operations/getallcontracts.go - - internal/sdk/models/operations/getallfiles.go - - internal/sdk/models/operations/getallopportunities.go - - internal/sdk/models/operations/getallorders.go - - internal/sdk/models/operations/getallportalconfigs.go - - internal/sdk/models/operations/getallrequests.go - - internal/sdk/models/operations/getautomationcontext.go - - internal/sdk/models/operations/getbillingevents.go - - internal/sdk/models/operations/getconsumption.go - - internal/sdk/models/operations/getcontact.go - - internal/sdk/models/operations/getcontract.go - - internal/sdk/models/operations/getcosts.go - - internal/sdk/models/operations/getcustomerbalance.go - - internal/sdk/models/operations/getdefaultpages.go - - internal/sdk/models/operations/getecpcontact.go - - internal/sdk/models/operations/getemailtemplates.go - - internal/sdk/models/operations/getentityactivityfeed.go - - internal/sdk/models/operations/getentityidentifiers.go - - internal/sdk/models/operations/getexternallinks.go - - internal/sdk/models/operations/getfilebyid.go - - internal/sdk/models/operations/getfilescountbyentity.go - - internal/sdk/models/operations/getjuicesettings.go - - internal/sdk/models/operations/getopportunity.go - - internal/sdk/models/operations/getorder.go - - internal/sdk/models/operations/getorganizationsettings.go - - internal/sdk/models/operations/getorganizationsettingsbydomain.go - - internal/sdk/models/operations/getorgportalconfig.go - - internal/sdk/models/operations/getportalconfig.go - - internal/sdk/models/operations/getportalconfigbydomain.go - - internal/sdk/models/operations/getportalconfigv3.go - - internal/sdk/models/operations/getportalextensions.go - - internal/sdk/models/operations/getportalpage.go - - internal/sdk/models/operations/getportalpageblock.go - - internal/sdk/models/operations/getportalpageblocks.go - - internal/sdk/models/operations/getportalpages.go - - internal/sdk/models/operations/getportaluser.go - - internal/sdk/models/operations/getportalwidgets.go - - internal/sdk/models/operations/getprices.go - - internal/sdk/models/operations/getpublicpages.go - - internal/sdk/models/operations/getpublicportalconfig.go - - internal/sdk/models/operations/getpublicportalextensiondetails.go - - internal/sdk/models/operations/getpublicportalwidgets.go - - internal/sdk/models/operations/getrecipientstonotifyonautomation.go - - internal/sdk/models/operations/getregistrationidentifiers.go - - internal/sdk/models/operations/getresolvedexternallink.go - - internal/sdk/models/operations/getresolvedseamlesslink.go - - internal/sdk/models/operations/getschemas.go - - internal/sdk/models/operations/getschemasbydomain.go - - internal/sdk/models/operations/getsearchableattributesforopportunities.go - - internal/sdk/models/operations/getsearchresultsforopportunities.go - - internal/sdk/models/operations/getuserentrypoint.go - - internal/sdk/models/operations/getvalidsecondaryattributes.go - - internal/sdk/models/operations/listallportalconfigs.go - - internal/sdk/models/operations/listportalsinternal.go - - internal/sdk/models/operations/logintoportalasuser.go - - internal/sdk/models/operations/notifymlogininterestchange.go + - internal/sdk/models/operations/addassignment.go + - internal/sdk/models/operations/assignroles.go + - internal/sdk/models/operations/createrole.go + - internal/sdk/models/operations/deleterole.go + - internal/sdk/models/operations/getassignedrolesforuser.go + - internal/sdk/models/operations/getrole.go + - internal/sdk/models/operations/listallassignments.go + - internal/sdk/models/operations/listallroles.go + - internal/sdk/models/operations/listcurrentroles.go - internal/sdk/models/operations/options.go - - internal/sdk/models/operations/postorderacceptance.go - - internal/sdk/models/operations/putportalconfig.go - - internal/sdk/models/operations/replaceecptemplatevariables.go - - internal/sdk/models/operations/resendconfirmationemail.go - - internal/sdk/models/operations/revoketoken.go - - internal/sdk/models/operations/saveentityfile.go - - internal/sdk/models/operations/saveportalfiles.go - - internal/sdk/models/operations/searchpaymentrelationsinentities.go - - internal/sdk/models/operations/searchportaluserentities.go - - internal/sdk/models/operations/ssocallback.go - - internal/sdk/models/operations/ssologin.go - - internal/sdk/models/operations/ssoredirect.go - - internal/sdk/models/operations/swapportalconfig.go - - internal/sdk/models/operations/trackfiledownloaded.go - - internal/sdk/models/operations/triggerentityaccessevent.go - - internal/sdk/models/operations/updatecampaignportalblockstatus.go - - internal/sdk/models/operations/updatecontact.go - - internal/sdk/models/operations/updatecontract.go - - internal/sdk/models/operations/updateopportunity.go - - internal/sdk/models/operations/updateorder.go - - internal/sdk/models/operations/updateportalpage.go - - internal/sdk/models/operations/updateportalpageblock.go - - internal/sdk/models/operations/updateportaluser.go - - internal/sdk/models/operations/updateportaluseremail.go - - internal/sdk/models/operations/updateworkflowstepasdone.go - - internal/sdk/models/operations/uploadmeterreadingphoto.go - - internal/sdk/models/operations/upsertemailtemplates.go - - internal/sdk/models/operations/upsertportal.go - - internal/sdk/models/operations/upsertportalwidget.go - - internal/sdk/models/operations/userexists.go - - internal/sdk/models/operations/validatecaarecords.go - - internal/sdk/models/operations/validatecadenceentityeditrules.go - - internal/sdk/models/operations/validatetoken.go - - internal/sdk/models/shared/acceptancedecision.go - - internal/sdk/models/shared/actionlabel.go - - internal/sdk/models/shared/actionwidget.go - - internal/sdk/models/shared/activitycallercontext.go - - internal/sdk/models/shared/activityitem.go - - internal/sdk/models/shared/adminuser.go - - internal/sdk/models/shared/allowedfileextensions.go - - internal/sdk/models/shared/balance.go - - internal/sdk/models/shared/billingevent.go - - internal/sdk/models/shared/block.go - - internal/sdk/models/shared/blockprops.go - - internal/sdk/models/shared/blockrequest.go - - internal/sdk/models/shared/campaignwidget.go - - internal/sdk/models/shared/contact.go - - internal/sdk/models/shared/contactexistsrequest.go - - internal/sdk/models/shared/contentwidget.go - - internal/sdk/models/shared/contract.go - - internal/sdk/models/shared/contractidentifier.go - - internal/sdk/models/shared/createuserrequest.go - - internal/sdk/models/shared/dataretrievalitem.go - - internal/sdk/models/shared/deleteentityfile.go - - internal/sdk/models/shared/emailtemplates.go - - internal/sdk/models/shared/entityeditrule.go - - internal/sdk/models/shared/entityfilecount.go - - internal/sdk/models/shared/entityitem.go - - internal/sdk/models/shared/entityresponsegroupedwithhits.go - - internal/sdk/models/shared/entityresponsewithhits.go - - internal/sdk/models/shared/entitysearchparams.go - - internal/sdk/models/shared/entityslug.go - - internal/sdk/models/shared/entitywidget.go - - internal/sdk/models/shared/errorresp.go - - internal/sdk/models/shared/extension.go - - internal/sdk/models/shared/extensionauthblock.go - - internal/sdk/models/shared/extensionconfig.go - - internal/sdk/models/shared/extensionhookconfig.go - - internal/sdk/models/shared/extensionseamlesslink.go - - internal/sdk/models/shared/externallink.go - - internal/sdk/models/shared/extraschemaattributes.go - - internal/sdk/models/shared/failedruleerrorresp.go - - internal/sdk/models/shared/file.go - - internal/sdk/models/shared/fileitem.go + - internal/sdk/models/operations/putrole.go + - internal/sdk/models/operations/refreshpermissions.go + - internal/sdk/models/operations/removeassignment.go + - internal/sdk/models/operations/searchroles.go + - internal/sdk/models/shared/assignment.go + - internal/sdk/models/shared/createrolepayload.go + - internal/sdk/models/shared/equalscondition.go - internal/sdk/models/shared/grant.go - - internal/sdk/models/shared/identifierattribute.go - - internal/sdk/models/shared/journeyactions.go - - internal/sdk/models/shared/juicesettings.go - - internal/sdk/models/shared/meter.go - - internal/sdk/models/shared/meterchartwidget.go - - internal/sdk/models/shared/meterreadingphoto.go - - internal/sdk/models/shared/meterreadingphotodata.go - - internal/sdk/models/shared/meterreadingwidget.go - - internal/sdk/models/shared/moblieoidcconfig.go - - internal/sdk/models/shared/oidcproviderconfig.go - - internal/sdk/models/shared/oidcprovidermetadata.go - - internal/sdk/models/shared/opportunity.go - - internal/sdk/models/shared/order.go - - internal/sdk/models/shared/organizationsettings.go - - internal/sdk/models/shared/page.go - - internal/sdk/models/shared/pagerequest.go - - internal/sdk/models/shared/portalconfig.go - - internal/sdk/models/shared/portalconfigv3.go - - internal/sdk/models/shared/portaluser.go - - internal/sdk/models/shared/product.go - - internal/sdk/models/shared/providerpublicconfig.go - - internal/sdk/models/shared/publiccontractidentificationdetails.go - - internal/sdk/models/shared/publicdataretrievalhookdetails.go - - internal/sdk/models/shared/publicextensioncapabilities.go - - internal/sdk/models/shared/publicextensiondetails.go - - internal/sdk/models/shared/rule.go - - internal/sdk/models/shared/saveentityfile.go - - internal/sdk/models/shared/saveportalfile.go - - internal/sdk/models/shared/schema.go + - internal/sdk/models/shared/grantcondition.go + - internal/sdk/models/shared/grantwithdependencies.go + - internal/sdk/models/shared/orgrole.go + - internal/sdk/models/shared/partnerrole.go + - internal/sdk/models/shared/portalrole.go + - internal/sdk/models/shared/role.go + - internal/sdk/models/shared/rolepayload.go + - internal/sdk/models/shared/rolesearchinput.go - internal/sdk/models/shared/security.go - - internal/sdk/models/shared/ssocallbackrequest.go - - internal/sdk/models/shared/ssocallbackresponse.go - - internal/sdk/models/shared/swappableconfig.go - - internal/sdk/models/shared/teaserwidget.go - - internal/sdk/models/shared/triggerportalflow.go - - internal/sdk/models/shared/upsertportalconfig.go - - internal/sdk/models/shared/upsertportalconfigv3.go - - internal/sdk/models/shared/upsertportalwidget.go - - internal/sdk/models/shared/widgetaction.go - - internal/sdk/models/shared/widgetbase.go - - internal/sdk/public.go + - internal/sdk/models/shared/sharerole.go + - internal/sdk/models/shared/userrole.go + - internal/sdk/optionalnullable/optionalnullable.go + - internal/sdk/optionalnullable/optionalnullable_test.go - internal/sdk/retry/config.go + - internal/sdk/roles.go - internal/sdk/sdk.go - internal/sdk/types/bigint.go - internal/sdk/types/date.go - internal/sdk/types/datetime.go - - internal/sdk/types/decimal.go - internal/sdk/types/pointers.go - internal/validators/DateValidator.go - internal/validators/ExactlyOneChild.go @@ -1617,5 +1405,97 @@ examples: application/json: {} "500": application/json: {} + addAssignment: + speakeasy-default-add-assignment: + parameters: + path: + userId: "1" + roleId: "123:owner" + responses: + "201": + application/json: {"roles": ["123:owner"], "user_id": "1"} + assignRoles: + speakeasy-default-assign-roles: + parameters: + path: + userId: "1" + requestBody: + application/json: ["123:owner"] + responses: + "200": + application/json: ["123:owner"] + getAssignedRolesForUser: + speakeasy-default-get-assigned-roles-for-user: + parameters: + path: + userId: "1" + responses: + "200": + application/json: ["123:owner"] + listAllAssignments: + speakeasy-default-list-all-assignments: + responses: + "200": + application/json: {"assignments": [{"roles": ["123:owner"], "user_id": "1"}]} + removeAssignment: + speakeasy-default-remove-assignment: + parameters: + path: + userId: "1" + roleId: "123:owner" + responses: + "200": + application/json: {"roles": ["123:owner"], "user_id": "1"} + createRole: + speakeasy-default-create-role: + requestBody: + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "id": "123:owner", "name": "Owner", "organization_id": "123", "pricing_tier": "Professional", "slug": "owner", "type": ""} + responses: + "200": + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [], "id": "123:owner", "name": "Owner", "organization_id": "123", "slug": "owner", "type": "share_role"} + deleteRole: + speakeasy-default-delete-role: + parameters: + path: + roleId: "123:owner" + responses: + "200": + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [], "id": "123:owner", "name": "Owner", "organization_id": "123", "partner_org_id": "123", "slug": "owner", "type": "partner_role"} + getRole: + speakeasy-default-get-role: + parameters: + path: + roleId: "123:owner" + responses: + "200": + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "id": "123:owner", "name": "Owner", "organization_id": "123", "slug": "owner", "type": "share_role"} + listAllRoles: + speakeasy-default-list-all-roles: + responses: + "200": + application/json: {"roles": [{"expires_at": "2028-07-21T17:32:28Z", "grants": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "id": "123:owner", "name": "Owner", "organization_id": "123", "pricing_tier": "Professional", "slug": "owner", "type": "org_role"}]} + listCurrentRoles: + speakeasy-default-list-current-roles: + responses: + "200": + application/json: {"roles": [{"expires_at": "2028-07-21T17:32:28Z", "grants": [], "id": "123:owner", "name": "Owner", "organization_id": "123", "slug": "owner", "type": "share_role"}]} + putRole: + speakeasy-default-put-role: + parameters: + path: + roleId: "123:owner" + requestBody: + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "dependencies": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "id": "123:owner", "name": "Owner", "organization_id": "123", "slug": "owner", "type": "share_role"} + responses: + "200": + application/json: {"expires_at": "2028-07-21T17:32:28Z", "grants": [{"action": "entity-read", "conditions": [{"attribute": "workflows.primary.task_name", "operation": "equals", "values": ["Qualification"]}], "effect": "allow", "resource": "entity:123:contact:f7c22299-ca72-4bca-8538-0a88eeefc947"}], "id": "123:owner", "name": "Owner", "organization_id": "123", "slug": "owner", "type": "share_role"} + refreshPermissions: {} + searchRoles: + speakeasy-default-search-roles: + requestBody: + application/json: {"limit": 1, "offset": 1, "org_ids": ["123", "456"], "query": "Administrator", "role_ids": ["123:manager", "456:owner"], "slugs": ["manager", "owner"]} + responses: + "200": + application/json: {"results": [{"expires_at": "2028-07-21T17:32:28Z", "grants": [], "id": "123:owner", "name": "Owner", "organization_id": "123", "partner_org_id": "123", "slug": "owner", "type": "partner_role"}]} examplesVersion: 1.0.2 generatedTests: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..92534c6 --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,31 @@ +speakeasyVersion: 1.642.2 +sources: + my-source: + sourceNamespace: my-source + sourceRevisionDigest: sha256:4e6c4720f5c8bf964fc9ee81cc4e85027f5202939285cd55071012f98c2a8a3e + sourceBlobDigest: sha256:d61afdb31421812d5d95eda6c4150e610cafb777447d8cc79320121ea8464be4 + tags: + - latest + - speakeasy-sdk-regen-1758760315 + - 1.0.0 +targets: + terraform: + source: my-source + sourceNamespace: my-source + sourceRevisionDigest: sha256:4e6c4720f5c8bf964fc9ee81cc4e85027f5202939285cd55071012f98c2a8a3e + sourceBlobDigest: sha256:d61afdb31421812d5d95eda6c4150e610cafb777447d8cc79320121ea8464be4 +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + sources: + my-source: + inputs: + - location: https://docs.api.epilot.io/permissions.yaml + overlays: + - location: overlay.yaml + registry: + location: registry.speakeasyapi.dev/epilot/epilot/my-source + targets: + terraform: + target: terraform + source: my-source diff --git a/README.md b/README.md index 9b37ca6..de7dd6d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ It has been generated successfully based on your OpenAPI spec. However, it is no ## Summary -Portal API: Backend for epilot portals - End Customer Portal & Installer Portal +Permissions API: Flexible Role-based Access Control for epilot @@ -48,7 +48,7 @@ terraform { required_providers { epilot-portal = { source = "epilot-dev/epilot-portal" - version = "0.25.16" + version = "0.26.0" } } } @@ -68,9 +68,8 @@ Available configuration: | Provider Attribute | Description | |---|---| -| `either_auth` | Portal or Epilot Bearer Token. | -| `epilot_auth` | Epilot Bearer Token. | -| `portal_auth` | Portal Cognito Token. | +| `epilot_auth` | Authorization header with epilot OAuth2 bearer token. | +| `epilot_org` | Overrides the target organization to allow shared tenantaccess. | @@ -78,12 +77,7 @@ Available configuration: ### Resources -* [epilot-portal_portal_config](docs/resources/portal_config.md) -* [epilot-portal_portal_page](docs/resources/portal_page.md) ### Data Sources - -* [epilot-portal_portal_config](docs/data-sources/portal_config.md) -* [epilot-portal_portal_page](docs/data-sources/portal_page.md) diff --git a/RELEASES.md b/RELEASES.md index f4a2be8..9eee343 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -14,4 +14,14 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.147.0 (2.237.2) https://github.com/speakeasy-api/speakeasy ### Generated -- [terraform v0.4.4] . \ No newline at end of file +- [terraform v0.4.4] . + +## 2025-10-30 00:33:52 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.642.2 (2.731.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.26.0] . +### Releases +- [Terraform v0.26.0] https://registry.terraform.io/providers/epilot-dev/epilot-portal/0.26.0 - . \ No newline at end of file diff --git a/docs/data-sources/portal_config.md b/docs/data-sources/portal_config.md deleted file mode 100644 index 5b8ccc2..0000000 --- a/docs/data-sources/portal_config.md +++ /dev/null @@ -1,309 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-portal_portal_config Data Source - terraform-provider-epilot-portal" -subcategory: "" -description: |- - PortalConfig DataSource ---- - -# epilot-portal_portal_config (Data Source) - -PortalConfig DataSource - -## Example Usage - -```terraform -data "epilot-portal_portal_config" "my_portalconfig" { - portal_id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} -``` - - -## Schema - -### Required - -- `portal_id` (String) Portal ID (readonly UUID generated on portal creation) - -### Read-Only - -- `access_token` (String) Access token for the portal -- `advanced_mfa` (Attributes) (see [below for nested schema](#nestedatt--advanced_mfa)) -- `allowed_file_extensions` (Attributes) Allowed file extensions for upload (see [below for nested schema](#nestedatt--allowed_file_extensions)) -- `approval_state_attributes` (String) Parsed as JSON. -- `auth_settings` (Attributes) Authentication settings for the portal (see [below for nested schema](#nestedatt--auth_settings)) -- `cognito_details` (Attributes) AWS Cognito Pool details for the portal (see [below for nested schema](#nestedatt--cognito_details)) -- `config` (String) Stringified object with configuration details -- `contact_identifiers` (List of String, Deprecated) Deprecated. Use registration_identifiers instead. -- `contract_identifiers` (String) Identifiers to identify a contract by a portal user. Parsed as JSON. -- `contract_selector_config` (Attributes) Configuration for contract selector in the portal (see [below for nested schema](#nestedatt--contract_selector_config)) -- `default_user_to_notify` (Attributes) Default 360 user to notify upon an internal notification (see [below for nested schema](#nestedatt--default_user_to_notify)) -- `design_id` (String) Entity ID -- `domain` (String) The URL on which the portal is accessible -- `email_templates` (Attributes) Email templates used for authentication and internal processes (see [below for nested schema](#nestedatt--email_templates)) -- `enabled` (Boolean) Enable/Disable the portal access -- `entity_actions` (Attributes List) Journey actions allowed on an entity by a portal user (see [below for nested schema](#nestedatt--entity_actions)) -- `entity_edit_rules` (String) Rules for editing an entity by a portal user. Parsed as JSON. -- `entity_identifiers` (Attributes, Deprecated) Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. (see [below for nested schema](#nestedatt--entity_identifiers)) -- `extension_hooks` (Attributes Map) Configured Portal extensions hooks (see [below for nested schema](#nestedatt--extension_hooks)) -- `extensions` (Attributes List) Configured Portal extensions (see [below for nested schema](#nestedatt--extensions)) -- `feature_flags` (String) Feature flags for the portal. Parsed as JSON. -- `feature_settings` (Attributes) Feature settings for the portal (see [below for nested schema](#nestedatt--feature_settings)) -- `grants` (String) Permissions granted to a portal user while accessing entities. Parsed as JSON. -- `identity_providers` (String) Parsed as JSON. -- `images` (Attributes) Teaser & Banner Image web links (see [below for nested schema](#nestedatt--images)) -- `inactive_contract_cutoff_years` (Number) Number of years to look back for showing inactive contracts in the portal -- `is_dummy` (Boolean) Whether this is a dummy/test portal configuration -- `is_epilot_domain` (Boolean) Mark true if the domain is an Epilot domain -- `is_v3_item` (Boolean) Whether this is a v3 portal configuration -- `meter_reading_grace_period` (Number) Grace period in days for meter readings -- `name` (String) A short name to identify your portal -- `org_settings` (Attributes) Organization settings (see [below for nested schema](#nestedatt--org_settings)) -- `organization_id` (String) ID of the organization -- `origin` (String) Origin of the portal -- `pages` (String) Parsed as JSON. -- `portal_sk_v3` (String) Key of the portal config -- `prevent_search_engine_indexing` (Boolean) Prevent indexing by search engines -- `registration_identifiers` (String) Identifiers to identify a contact of a portal user during the registration. Parsed as JSON. -- `self_registration_setting` (String) -- `triggered_journeys` (Attributes List) Journeys automatically opened on a portal user action (see [below for nested schema](#nestedatt--triggered_journeys)) - - -### Nested Schema for `advanced_mfa` - -Read-Only: - -- `enabled` (Boolean) Advanced MFA feature flag - - - -### Nested Schema for `allowed_file_extensions` - -Read-Only: - -- `archive` (List of String) -- `audio_video` (List of String) -- `cad` (List of String) -- `calendar` (List of String) -- `document` (List of String) -- `email` (List of String) -- `image` (List of String) -- `other` (List of String) -- `presentation` (List of String) -- `spreadsheet` (List of String) - - - -### Nested Schema for `auth_settings` - -Read-Only: - -- `auto_redirect_to_sso` (Boolean) Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. -- `entry_point` (String) -- `passwordless_login` (Attributes) (see [below for nested schema](#nestedatt--auth_settings--passwordless_login)) -- `preferred_sso_providers` (List of String) - - -### Nested Schema for `auth_settings.passwordless_login` - -Read-Only: - -- `enabled` (Boolean) Passwordless login feature flag - - - - -### Nested Schema for `cognito_details` - -Read-Only: - -- `cognito_user_pool_arn` (String) Cognito user pool ARN -- `cognito_user_pool_client_id` (String) Cognito user pool client ID -- `cognito_user_pool_id` (String) Cognito user pool ID -- `password_policy` (Attributes) Password policy for the portal (see [below for nested schema](#nestedatt--cognito_details--password_policy)) - - -### Nested Schema for `cognito_details.password_policy` - -Read-Only: - -- `minimum_length` (Number) Minimum password length -- `require_lowercase` (Boolean) Require lowercase characters -- `require_numbers` (Boolean) Require numbers -- `require_symbols` (Boolean) Require symbols -- `require_uppercase` (Boolean) Require uppercase characters - - - - -### Nested Schema for `contract_selector_config` - -Read-Only: - -- `show_inactive` (Boolean) Whether to show inactive contracts in the selector -- `title_path` (String) Path to the property to use as the contract title - - - -### Nested Schema for `default_user_to_notify` - -Read-Only: - -- `on_pending_user` (Attributes List) Default admin users for pending user notification to notify (see [below for nested schema](#nestedatt--default_user_to_notify--on_pending_user)) - - -### Nested Schema for `default_user_to_notify.on_pending_user` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `display_name` (String) -- `email` (String) -- `image_uri` (Attributes) (see [below for nested schema](#nestedatt--default_user_to_notify--on_pending_user--image_uri)) -- `org_id` (String) -- `phone` (String) -- `type` (String) -- `user_id` (String) - - -### Nested Schema for `default_user_to_notify.on_pending_user.image_uri` - -Read-Only: - -- `key` (String) -- `original` (String) -- `thumbnail_32` (String) -- `thumbnail_64` (String) - - - - - -### Nested Schema for `email_templates` - -Read-Only: - -- `advanced_auth` (String) Entity ID -- `advanced_mfa` (String) Entity ID -- `confirm_account` (String) Entity ID -- `confirm_email_update` (String) Entity ID -- `forgot_password` (String) Entity ID -- `invitation` (String) Entity ID -- `journey_login_otp` (String) Entity ID -- `journey_sign_in_one_time_password` (String) Entity ID -- `journey_sign_up` (String) Entity ID -- `on_doc_upload` (String) Entity ID -- `on_map_a_pending_user` (String) Entity ID -- `on_new_quote` (String) Entity ID -- `on_workflow_step_assigned` (String) Entity ID -- `verify_code_to_set_password` (String) Entity ID - - - -### Nested Schema for `entity_actions` - -Read-Only: - -- `action_label` (Attributes) (see [below for nested schema](#nestedatt--entity_actions--action_label)) -- `journey_id` (String) Entity ID -- `slug` (String) URL-friendly identifier for the entity schema - - -### Nested Schema for `entity_actions.action_label` - -Read-Only: - -- `de` (String) -- `en` (String) - - - - -### Nested Schema for `entity_identifiers` - -Read-Only: - -- `type` (Attributes) (see [below for nested schema](#nestedatt--entity_identifiers--type)) - - -### Nested Schema for `entity_identifiers.type` - -Read-Only: - -- `attributes` (List of String) Attributes used to identify an entity -- `is_enabled` (Boolean) Enable/Disable the entity identifier - - - - -### Nested Schema for `extension_hooks` - -Read-Only: - -- `app_id` (String) The ID of the app that is being hooked into. -- `hook_id` (String) The ID of the hook that is being configured. - - - -### Nested Schema for `extensions` - -Read-Only: - -- `id` (String) Name of the extension -- `options` (Map of String) Extension option values. -- `status` (String) Status of the extension - - - -### Nested Schema for `feature_settings` - -Read-Only: - -- `billing` (Boolean) Billing feature flag -- `change_due_date` (Boolean) Change due date feature flag -- `new_design` (Boolean) Enable or disable the new design for the portal -- `start_page` (Boolean) Start page feature flag - - - -### Nested Schema for `images` - -Read-Only: - -- `order_left_teaser` (String) URL of the order left teaser image -- `order_right_teaser` (String) URL of the order right teaser image -- `welcome_banner` (String) URL of the welcome banner image - - - -### Nested Schema for `org_settings` - -Read-Only: - -- `canary` (Attributes) Canary feature flag (see [below for nested schema](#nestedatt--org_settings--canary)) -- `notracking` (Attributes) Disable Advanced Usage Metrics (see [below for nested schema](#nestedatt--org_settings--notracking)) - - -### Nested Schema for `org_settings.canary` - -Read-Only: - -- `enabled` (Boolean) Enable/Disable the canary feature - - - -### Nested Schema for `org_settings.notracking` - -Read-Only: - -- `enabled` (Boolean) Disable browser-side scripts that track advanced usage metrics - - - - -### Nested Schema for `triggered_journeys` - -Read-Only: - -- `journey_id` (String) Entity ID -- `trigger_name` (String) diff --git a/docs/data-sources/portal_page.md b/docs/data-sources/portal_page.md deleted file mode 100644 index 66d2a33..0000000 --- a/docs/data-sources/portal_page.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-portal_portal_page Data Source - terraform-provider-epilot-portal" -subcategory: "" -description: |- - PortalPage DataSource ---- - -# epilot-portal_portal_page (Data Source) - -PortalPage DataSource - -## Example Usage - -```terraform -data "epilot-portal_portal_page" "my_portalpage" { - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} -``` - - -## Schema - -### Read-Only - -- `additional_properties` (String) Parsed as JSON. -- `blocks` (Attributes Map) (see [below for nested schema](#nestedatt--blocks)) -- `content` (Map of String) The content of the page -- `design` (Map of String) The design of the page -- `id` (String) The ID of this resource. -- `is_deleted` (Boolean) Send the flag as true to delete the page -- `is_entry_route` (Boolean) Whether the page is the entry route -- `is_public` (Boolean) Whether the page is public -- `is_system` (Boolean) Whether the page is a system page -- `last_modified_at` (String) Last modified timestamp of the Page -- `order` (Number) The order of the block -- `parent_id` (String) The id of the parent page -- `path` (String, Deprecated) The path of the page -- `schema` (List of String) -- `slug` (String) The slug of the page -- `visibility` (Map of String) The conditions that need to be met for the page to be shown - - -### Nested Schema for `blocks` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `id` (String) The id of the block -- `order` (Number) The order of the block -- `parent_id` (String) The id of the parent block -- `props` (Attributes) (see [below for nested schema](#nestedatt--blocks--props)) -- `type` (String) The type of the block. eg; tabs, tab, group, attribute - - -### Nested Schema for `blocks.props` - -Read-Only: - -- `additional_properties` (String) Parsed as JSON. -- `content` (Map of String) The content of the block -- `design` (Map of String) The design of the block -- `visibility` (Map of String) The conditions that need to be met for the block to be shown diff --git a/docs/index.md b/docs/index.md index 4852a10..c019cab 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,12 +2,12 @@ # generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "epilot-portal Provider" description: |- - Portal API: Backend for epilot portals - End Customer Portal & Installer Portal + Permissions API: Flexible Role-based Access Control for epilot --- # epilot-portal Provider -Portal API: Backend for epilot portals - End Customer Portal & Installer Portal +Permissions API: Flexible Role-based Access Control for epilot ## Example Usage @@ -16,7 +16,7 @@ terraform { required_providers { epilot-portal = { source = "epilot-dev/epilot-portal" - version = "0.25.16" + version = "0.26.0" } } } @@ -31,7 +31,6 @@ provider "epilot-portal" { ### Optional -- `either_auth` (String, Sensitive) Portal or Epilot Bearer Token. -- `epilot_auth` (String, Sensitive) Epilot Bearer Token. -- `portal_auth` (String, Sensitive) Portal Cognito Token. -- `server_url` (String) Server URL (defaults to https://customer-portal-api.sls.epilot.io/) +- `epilot_auth` (String, Sensitive) Authorization header with epilot OAuth2 bearer token. +- `epilot_org` (String, Sensitive) Overrides the target organization to allow shared tenantaccess. +- `server_url` (String) Server URL (defaults to https://permissions.sls.epilot.io) diff --git a/docs/resources/portal_config.md b/docs/resources/portal_config.md deleted file mode 100644 index 9554d29..0000000 --- a/docs/resources/portal_config.md +++ /dev/null @@ -1,497 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-portal_portal_config Resource - terraform-provider-epilot-portal" -subcategory: "" -description: |- - PortalConfig Resource ---- - -# epilot-portal_portal_config (Resource) - -PortalConfig Resource - -## Example Usage - -```terraform -resource "epilot-portal_portal_config" "my_portalconfig" { - access_token = "...my_access_token..." - advanced_mfa = { - enabled = true - } - allowed_file_extensions = { - archive = [ - "zip" - ] - audio_video = [ - "mp4" - ] - cad = [ - "cad" - ] - calendar = [ - "ics" - ] - document = [ - "pdf" - ] - email = [ - "eml" - ] - image = [ - "jpg" - ] - other = [ - "txt" - ] - presentation = [ - "ppt" - ] - spreadsheet = [ - "xls" - ] - } - approval_state_attributes = "{ \"see\": \"documentation\" }" - auth_settings = { - auto_redirect_to_sso = true - entry_point = "SSO" - passwordless_login = { - enabled = true - } - preferred_sso_providers = [ - "office-365-login" - ] - } - cognito_details = { - cognito_user_pool_arn = "arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_123412341" - cognito_user_pool_client_id = "6bsd0jkgoie74k2i8mrhc1vest" - cognito_user_pool_id = "eu-central-1_CUEQRNbUb" - password_policy = { - minimum_length = 8 - require_lowercase = true - require_numbers = true - require_symbols = true - require_uppercase = true - } - } - config = "...my_config..." - contact_identifiers = [ - "email", - "last_name", - ] - contract_identifiers = "{ \"see\": \"documentation\" }" - contract_selector_config = { - show_inactive = false - title_path = "...my_title_path..." - } - default_user_to_notify = { - on_pending_user = [ - { - additional_properties = "{ \"see\": \"documentation\" }" - display_name = "John" - email = "j.doe@epilot.cloud" - image_uri = { - key = "fuafjvoHKsudhfagweucjasdvga" - original = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original" - thumbnail_32 = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original?w=32&h=32" - thumbnail_64 = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original?w=64&h=64" - } - org_id = "123" - phone = "12345 67890" - type = "user" - user_id = "123456" - } - ] - } - design_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - domain = "abc.com" - email_templates = { - advanced_auth = "5da0a718-c822-403d-9f5d-20d4584e0528" - advanced_mfa = "5da0a718-c822-403d-9f5d-20d4584e0528" - confirm_account = "5da0a718-c822-403d-9f5d-20d4584e0528" - confirm_email_update = "5da0a718-c822-403d-9f5d-20d4584e0528" - forgot_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - invitation = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_login_otp = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_sign_in_one_time_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_sign_up = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_doc_upload = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_map_a_pending_user = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_new_quote = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_workflow_step_assigned = "5da0a718-c822-403d-9f5d-20d4584e0528" - verify_code_to_set_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - } - enabled = false - entity_actions = [ - { - action_label = { - de = "...my_de..." - en = "...my_en..." - } - journey_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - slug = "contact" - } - ] - entity_edit_rules = "{ \"see\": \"documentation\" }" - entity_identifiers = { - type = { - attributes = [ - "contract_number" - ] - is_enabled = false - } - } - extension_hooks = { - key = { - app_id = "...my_app_id..." - hook_id = "...my_hook_id..." - } - } - extensions = [ - { - id = "...my_id..." - options = { - key = "value" - } - status = "installed" - } - ] - feature_settings = { - billing = true - change_due_date = false - new_design = true - start_page = true - } - images = { - order_left_teaser = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/order-left-teaser.jpeg" - order_right_teaser = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/order-right-teaser.jpeg" - welcome_banner = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/welcome-banner.jpeg" - } - inactive_contract_cutoff_years = 6.78 - is_dummy = true - is_epilot_domain = true - is_v3_item = true - meter_reading_grace_period = 9.12 - name = "Installer Portal" - origin = "...my_origin..." - pages = "{ \"see\": \"documentation\" }" - portal_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - portal_sk_v3 = "PORTAL_CONFIG#453ad7bf-86d5-46c8-8252-bcc868df5e3c" - prevent_search_engine_indexing = true - registration_identifiers = "{ \"see\": \"documentation\" }" - self_registration_setting = "ALLOW_WITHOUT_CONTACT_CREATION" - triggered_journeys = [ - { - journey_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - trigger_name = "DECLINE_ORDER" - } - ] -} -``` - - -## Schema - -### Optional - -- `access_token` (String) Access token for the portal -- `advanced_mfa` (Attributes) (see [below for nested schema](#nestedatt--advanced_mfa)) -- `allowed_file_extensions` (Attributes) Allowed file extensions for upload (see [below for nested schema](#nestedatt--allowed_file_extensions)) -- `approval_state_attributes` (String) Parsed as JSON. -- `auth_settings` (Attributes) Authentication settings for the portal (see [below for nested schema](#nestedatt--auth_settings)) -- `cognito_details` (Attributes) AWS Cognito Pool details for the portal (see [below for nested schema](#nestedatt--cognito_details)) -- `config` (String) Stringified object with configuration details -- `contact_identifiers` (List of String, Deprecated) Deprecated. Use registration_identifiers instead. -- `contract_identifiers` (String) Identifiers to identify a contract by a portal user. Parsed as JSON. -- `contract_selector_config` (Attributes) Configuration for contract selector in the portal (see [below for nested schema](#nestedatt--contract_selector_config)) -- `default_user_to_notify` (Attributes) Default 360 user to notify upon an internal notification (see [below for nested schema](#nestedatt--default_user_to_notify)) -- `design_id` (String) Entity ID -- `domain` (String) The URL on which the portal is accessible -- `email_templates` (Attributes) Email templates used for authentication and internal processes (see [below for nested schema](#nestedatt--email_templates)) -- `enabled` (Boolean) Enable/Disable the portal access -- `entity_actions` (Attributes List) Journey actions allowed on an entity by a portal user (see [below for nested schema](#nestedatt--entity_actions)) -- `entity_edit_rules` (String) Rules for editing an entity by a portal user. Parsed as JSON. -- `entity_identifiers` (Attributes, Deprecated) Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. (see [below for nested schema](#nestedatt--entity_identifiers)) -- `extension_hooks` (Attributes Map) Configured Portal extensions hooks (see [below for nested schema](#nestedatt--extension_hooks)) -- `extensions` (Attributes List) Configured Portal extensions (see [below for nested schema](#nestedatt--extensions)) -- `feature_settings` (Attributes) Feature settings for the portal (see [below for nested schema](#nestedatt--feature_settings)) -- `images` (Attributes) Teaser & Banner Image web links (see [below for nested schema](#nestedatt--images)) -- `inactive_contract_cutoff_years` (Number) Number of years to look back for showing inactive contracts in the portal -- `is_dummy` (Boolean) Whether this is a dummy/test portal configuration -- `is_epilot_domain` (Boolean) Mark true if the domain is an Epilot domain -- `is_v3_item` (Boolean) Whether this is a v3 portal configuration -- `meter_reading_grace_period` (Number) Grace period in days for meter readings -- `name` (String) A short name to identify your portal -- `origin` (String) Origin of the portal -- `pages` (String) Parsed as JSON. -- `portal_id` (String) ID of the portal -- `portal_sk_v3` (String) Key of the portal config -- `prevent_search_engine_indexing` (Boolean) Prevent indexing by search engines -- `registration_identifiers` (String) Identifiers to identify a contact of a portal user during the registration. Parsed as JSON. -- `self_registration_setting` (String) must be one of ["ALLOW_WITH_CONTACT_CREATION", "ALLOW_WITHOUT_CONTACT_CREATION", "DENY"] -- `triggered_journeys` (Attributes List) Journeys automatically opened on a portal user action (see [below for nested schema](#nestedatt--triggered_journeys)) - -### Read-Only - -- `feature_flags` (String) Feature flags for the portal. Parsed as JSON. -- `grants` (String) Permissions granted to a portal user while accessing entities. Parsed as JSON. -- `identity_providers` (String) Parsed as JSON. -- `org_settings` (Attributes) Organization settings (see [below for nested schema](#nestedatt--org_settings)) -- `organization_id` (String) ID of the organization - - -### Nested Schema for `advanced_mfa` - -Optional: - -- `enabled` (Boolean) Advanced MFA feature flag - - - -### Nested Schema for `allowed_file_extensions` - -Optional: - -- `archive` (List of String) -- `audio_video` (List of String) -- `cad` (List of String) -- `calendar` (List of String) -- `document` (List of String) -- `email` (List of String) -- `image` (List of String) -- `other` (List of String) -- `presentation` (List of String) -- `spreadsheet` (List of String) - - - -### Nested Schema for `auth_settings` - -Optional: - -- `auto_redirect_to_sso` (Boolean) Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. -- `entry_point` (String) must be one of ["PASSWORD", "SSO"] -- `passwordless_login` (Attributes) (see [below for nested schema](#nestedatt--auth_settings--passwordless_login)) -- `preferred_sso_providers` (List of String) - - -### Nested Schema for `auth_settings.passwordless_login` - -Optional: - -- `enabled` (Boolean) Passwordless login feature flag - - - - -### Nested Schema for `cognito_details` - -Optional: - -- `cognito_user_pool_arn` (String) Cognito user pool ARN -- `cognito_user_pool_client_id` (String) Cognito user pool client ID -- `cognito_user_pool_id` (String) Cognito user pool ID -- `password_policy` (Attributes) Password policy for the portal (see [below for nested schema](#nestedatt--cognito_details--password_policy)) - - -### Nested Schema for `cognito_details.password_policy` - -Optional: - -- `minimum_length` (Number) Minimum password length -- `require_lowercase` (Boolean) Require lowercase characters -- `require_numbers` (Boolean) Require numbers -- `require_symbols` (Boolean) Require symbols -- `require_uppercase` (Boolean) Require uppercase characters - - - - -### Nested Schema for `contract_selector_config` - -Optional: - -- `show_inactive` (Boolean) Whether to show inactive contracts in the selector -- `title_path` (String) Path to the property to use as the contract title - - - -### Nested Schema for `default_user_to_notify` - -Optional: - -- `on_pending_user` (Attributes List) Default admin users for pending user notification to notify (see [below for nested schema](#nestedatt--default_user_to_notify--on_pending_user)) - - -### Nested Schema for `default_user_to_notify.on_pending_user` - -Optional: - -- `additional_properties` (String) Parsed as JSON. -- `display_name` (String) -- `email` (String) -- `image_uri` (Attributes) (see [below for nested schema](#nestedatt--default_user_to_notify--on_pending_user--image_uri)) -- `org_id` (String) -- `phone` (String) -- `type` (String) -- `user_id` (String) - - -### Nested Schema for `default_user_to_notify.on_pending_user.image_uri` - -Optional: - -- `key` (String) -- `original` (String) -- `thumbnail_32` (String) -- `thumbnail_64` (String) - - - - - -### Nested Schema for `email_templates` - -Optional: - -- `advanced_auth` (String) Entity ID -- `advanced_mfa` (String) Entity ID -- `confirm_account` (String) Entity ID -- `confirm_email_update` (String) Entity ID -- `forgot_password` (String) Entity ID -- `invitation` (String) Entity ID -- `journey_login_otp` (String) Entity ID -- `journey_sign_in_one_time_password` (String) Entity ID -- `journey_sign_up` (String) Entity ID -- `on_doc_upload` (String) Entity ID -- `on_map_a_pending_user` (String) Entity ID -- `on_new_quote` (String) Entity ID -- `on_workflow_step_assigned` (String) Entity ID -- `verify_code_to_set_password` (String) Entity ID - - - -### Nested Schema for `entity_actions` - -Optional: - -- `action_label` (Attributes) (see [below for nested schema](#nestedatt--entity_actions--action_label)) -- `journey_id` (String) Entity ID -- `slug` (String) URL-friendly identifier for the entity schema. must be one of ["contact", "contract", "file", "order", "opportunity", "product", "price", "meter", "meter_counter"] - - -### Nested Schema for `entity_actions.action_label` - -Optional: - -- `de` (String) -- `en` (String) - - - - -### Nested Schema for `entity_identifiers` - -Optional: - -- `type` (Attributes) (see [below for nested schema](#nestedatt--entity_identifiers--type)) - - -### Nested Schema for `entity_identifiers.type` - -Optional: - -- `attributes` (List of String) Attributes used to identify an entity -- `is_enabled` (Boolean) Enable/Disable the entity identifier - - - - -### Nested Schema for `extension_hooks` - -Optional: - -- `app_id` (String) The ID of the app that is being hooked into. -- `hook_id` (String) The ID of the hook that is being configured. - - - -### Nested Schema for `extensions` - -Optional: - -- `id` (String) Name of the extension. Not Null -- `options` (Map of String) Extension option values. -- `status` (String) Status of the extension. Default: "installed"; must be one of ["installed", "enabled"] - - - -### Nested Schema for `feature_settings` - -Optional: - -- `billing` (Boolean) Billing feature flag -- `change_due_date` (Boolean) Change due date feature flag -- `new_design` (Boolean) Enable or disable the new design for the portal -- `start_page` (Boolean) Start page feature flag - - - -### Nested Schema for `images` - -Optional: - -- `order_left_teaser` (String) URL of the order left teaser image -- `order_right_teaser` (String) URL of the order right teaser image -- `welcome_banner` (String) URL of the welcome banner image - - - -### Nested Schema for `triggered_journeys` - -Optional: - -- `journey_id` (String) Entity ID -- `trigger_name` (String) must be one of ["FIRST_LOGIN", "ACCEPT_ORDER", "DECLINE_ORDER"] - - - -### Nested Schema for `org_settings` - -Read-Only: - -- `canary` (Attributes) Canary feature flag (see [below for nested schema](#nestedatt--org_settings--canary)) -- `notracking` (Attributes) Disable Advanced Usage Metrics (see [below for nested schema](#nestedatt--org_settings--notracking)) - - -### Nested Schema for `org_settings.canary` - -Read-Only: - -- `enabled` (Boolean) Enable/Disable the canary feature - - - -### Nested Schema for `org_settings.notracking` - -Read-Only: - -- `enabled` (Boolean) Disable browser-side scripts that track advanced usage metrics - -## Import - -Import is supported using the following syntax: - -In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: - -```terraform -import { - to = epilot-portal_portal_config.my_epilot-portal_portal_config - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} -``` - -The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: - -```shell -terraform import epilot-portal_portal_config.my_epilot-portal_portal_config "5da0a718-c822-403d-9f5d-20d4584e0528" -``` diff --git a/docs/resources/portal_page.md b/docs/resources/portal_page.md deleted file mode 100644 index 54d4fab..0000000 --- a/docs/resources/portal_page.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "epilot-portal_portal_page Resource - terraform-provider-epilot-portal" -subcategory: "" -description: |- - PortalPage Resource ---- - -# epilot-portal_portal_page (Resource) - -PortalPage Resource - -## Example Usage - -```terraform -resource "epilot-portal_portal_page" "my_portalpage" { - additional_properties = "{ \"see\": \"documentation\" }" - blocks = { - key = { - additional_properties = "{ \"see\": \"documentation\" }" - id = "c495fef9-eeca-4019-a989-8390dcd9825b" - order = 1 - parent_id = "c495fef9-eeca-4019-a989-8390dcd9825b" - props = { - additional_properties = "{ \"see\": \"documentation\" }" - content = { - key = jsonencode("value") - } - design = { - key = jsonencode("value") - } - visibility = { - key = jsonencode("value") - } - } - type = "tab" - } - } - content = { - key = jsonencode("value") - } - design = { - key = jsonencode("value") - } - domain = "customer-portal.epilot.io" - is_deleted = false - is_entry_route = false - is_public = true - is_system = false - order = 1 - parent_id = "c495fef9-eeca-4019-a989-8390dcd9825b" - path = "/dashboard" - schema = [ - "contract" - ] - slug = "dashboard" - visibility = { - key = jsonencode("value") - } -} -``` - - -## Schema - -### Required - -- `domain` (String) Requires replacement if changed. -- `order` (Number) The order of the block -- `slug` (String) The slug of the page - -### Optional - -- `additional_properties` (String) Parsed as JSON. -- `blocks` (Attributes Map) (see [below for nested schema](#nestedatt--blocks)) -- `content` (Map of String) The content of the page -- `design` (Map of String) The design of the page -- `is_deleted` (Boolean) Send the flag as true to delete the page -- `is_entry_route` (Boolean) Whether the page is the entry route -- `is_public` (Boolean) Whether the page is public -- `is_system` (Boolean) Whether the page is a system page -- `parent_id` (String) The id of the parent page -- `path` (String, Deprecated) The path of the page -- `schema` (List of String) -- `visibility` (Map of String) The conditions that need to be met for the page to be shown - -### Read-Only - -- `id` (String) The id of the page -- `last_modified_at` (String) Last modified timestamp of the Page - - -### Nested Schema for `blocks` - -Optional: - -- `additional_properties` (String) Parsed as JSON. -- `id` (String) The id of the block -- `order` (Number) The order of the block. Not Null -- `parent_id` (String) The id of the parent block -- `props` (Attributes) (see [below for nested schema](#nestedatt--blocks--props)) -- `type` (String) The type of the block. eg; tabs, tab, group, attribute. Not Null - - -### Nested Schema for `blocks.props` - -Optional: - -- `additional_properties` (String) Parsed as JSON. -- `content` (Map of String) The content of the block -- `design` (Map of String) The design of the block -- `visibility` (Map of String) The conditions that need to be met for the block to be shown - -## Import - -Import is supported using the following syntax: - -In Terraform v1.5.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `id` attribute, for example: - -```terraform -import { - to = epilot-portal_portal_page.my_epilot-portal_portal_page - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} -``` - -The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: - -```shell -terraform import epilot-portal_portal_page.my_epilot-portal_portal_page "5da0a718-c822-403d-9f5d-20d4584e0528" -``` diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index f87f5c1..0000000 --- a/examples/README.md +++ /dev/null @@ -1 +0,0 @@ -# TODO \ No newline at end of file diff --git a/examples/data-sources/epilot-portal_portal_config/data-source.tf b/examples/data-sources/epilot-portal_portal_config/data-source.tf deleted file mode 100644 index b4a8659..0000000 --- a/examples/data-sources/epilot-portal_portal_config/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "epilot-portal_portal_config" "my_portalconfig" { - portal_id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} \ No newline at end of file diff --git a/examples/data-sources/epilot-portal_portal_page/data-source.tf b/examples/data-sources/epilot-portal_portal_page/data-source.tf deleted file mode 100644 index bf5e9be..0000000 --- a/examples/data-sources/epilot-portal_portal_page/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "epilot-portal_portal_page" "my_portalpage" { - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index b938b6c..7e833f9 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-portal = { source = "epilot-dev/epilot-portal" - version = "0.25.16" + version = "0.26.0" } } } diff --git a/examples/resources/epilot-portal_portal_config/import-by-string-id.tf b/examples/resources/epilot-portal_portal_config/import-by-string-id.tf deleted file mode 100644 index 1d0b732..0000000 --- a/examples/resources/epilot-portal_portal_config/import-by-string-id.tf +++ /dev/null @@ -1,4 +0,0 @@ -import { - to = epilot-portal_portal_config.my_epilot-portal_portal_config - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} diff --git a/examples/resources/epilot-portal_portal_config/import.sh b/examples/resources/epilot-portal_portal_config/import.sh deleted file mode 100644 index d2dc264..0000000 --- a/examples/resources/epilot-portal_portal_config/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-portal_portal_config.my_epilot-portal_portal_config "5da0a718-c822-403d-9f5d-20d4584e0528" diff --git a/examples/resources/epilot-portal_portal_config/resource.tf b/examples/resources/epilot-portal_portal_config/resource.tf deleted file mode 100644 index 21b0377..0000000 --- a/examples/resources/epilot-portal_portal_config/resource.tf +++ /dev/null @@ -1,173 +0,0 @@ -resource "epilot-portal_portal_config" "my_portalconfig" { - access_token = "...my_access_token..." - advanced_mfa = { - enabled = true - } - allowed_file_extensions = { - archive = [ - "zip" - ] - audio_video = [ - "mp4" - ] - cad = [ - "cad" - ] - calendar = [ - "ics" - ] - document = [ - "pdf" - ] - email = [ - "eml" - ] - image = [ - "jpg" - ] - other = [ - "txt" - ] - presentation = [ - "ppt" - ] - spreadsheet = [ - "xls" - ] - } - approval_state_attributes = "{ \"see\": \"documentation\" }" - auth_settings = { - auto_redirect_to_sso = true - entry_point = "SSO" - passwordless_login = { - enabled = true - } - preferred_sso_providers = [ - "office-365-login" - ] - } - cognito_details = { - cognito_user_pool_arn = "arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_123412341" - cognito_user_pool_client_id = "6bsd0jkgoie74k2i8mrhc1vest" - cognito_user_pool_id = "eu-central-1_CUEQRNbUb" - password_policy = { - minimum_length = 8 - require_lowercase = true - require_numbers = true - require_symbols = true - require_uppercase = true - } - } - config = "...my_config..." - contact_identifiers = [ - "email", - "last_name", - ] - contract_identifiers = "{ \"see\": \"documentation\" }" - contract_selector_config = { - show_inactive = false - title_path = "...my_title_path..." - } - default_user_to_notify = { - on_pending_user = [ - { - additional_properties = "{ \"see\": \"documentation\" }" - display_name = "John" - email = "j.doe@epilot.cloud" - image_uri = { - key = "fuafjvoHKsudhfagweucjasdvga" - original = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original" - thumbnail_32 = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original?w=32&h=32" - thumbnail_64 = "https://fuafjvoHKsu.cloudimg.io/v7/e-mage-sam-bucket-dev.s3.eu-central-1.amazonaws.com/files/fuafjvoHKsudhfagweucjasdvga/original?w=64&h=64" - } - org_id = "123" - phone = "12345 67890" - type = "user" - user_id = "123456" - } - ] - } - design_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - domain = "abc.com" - email_templates = { - advanced_auth = "5da0a718-c822-403d-9f5d-20d4584e0528" - advanced_mfa = "5da0a718-c822-403d-9f5d-20d4584e0528" - confirm_account = "5da0a718-c822-403d-9f5d-20d4584e0528" - confirm_email_update = "5da0a718-c822-403d-9f5d-20d4584e0528" - forgot_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - invitation = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_login_otp = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_sign_in_one_time_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - journey_sign_up = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_doc_upload = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_map_a_pending_user = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_new_quote = "5da0a718-c822-403d-9f5d-20d4584e0528" - on_workflow_step_assigned = "5da0a718-c822-403d-9f5d-20d4584e0528" - verify_code_to_set_password = "5da0a718-c822-403d-9f5d-20d4584e0528" - } - enabled = false - entity_actions = [ - { - action_label = { - de = "...my_de..." - en = "...my_en..." - } - journey_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - slug = "contact" - } - ] - entity_edit_rules = "{ \"see\": \"documentation\" }" - entity_identifiers = { - type = { - attributes = [ - "contract_number" - ] - is_enabled = false - } - } - extension_hooks = { - key = { - app_id = "...my_app_id..." - hook_id = "...my_hook_id..." - } - } - extensions = [ - { - id = "...my_id..." - options = { - key = "value" - } - status = "installed" - } - ] - feature_settings = { - billing = true - change_due_date = false - new_design = true - start_page = true - } - images = { - order_left_teaser = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/order-left-teaser.jpeg" - order_right_teaser = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/order-right-teaser.jpeg" - welcome_banner = "https://epilot-bucket.s3.eu-central-1.amazonaws.com/12344/6538fddb-f0e9-4f0f-af51-6e57891ff20a/welcome-banner.jpeg" - } - inactive_contract_cutoff_years = 6.78 - is_dummy = true - is_epilot_domain = true - is_v3_item = true - meter_reading_grace_period = 9.12 - name = "Installer Portal" - origin = "...my_origin..." - pages = "{ \"see\": \"documentation\" }" - portal_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - portal_sk_v3 = "PORTAL_CONFIG#453ad7bf-86d5-46c8-8252-bcc868df5e3c" - prevent_search_engine_indexing = true - registration_identifiers = "{ \"see\": \"documentation\" }" - self_registration_setting = "ALLOW_WITHOUT_CONTACT_CREATION" - triggered_journeys = [ - { - journey_id = "5da0a718-c822-403d-9f5d-20d4584e0528" - trigger_name = "DECLINE_ORDER" - } - ] -} \ No newline at end of file diff --git a/examples/resources/epilot-portal_portal_page/import-by-string-id.tf b/examples/resources/epilot-portal_portal_page/import-by-string-id.tf deleted file mode 100644 index 60a745f..0000000 --- a/examples/resources/epilot-portal_portal_page/import-by-string-id.tf +++ /dev/null @@ -1,4 +0,0 @@ -import { - to = epilot-portal_portal_page.my_epilot-portal_portal_page - id = "5da0a718-c822-403d-9f5d-20d4584e0528" -} diff --git a/examples/resources/epilot-portal_portal_page/import.sh b/examples/resources/epilot-portal_portal_page/import.sh deleted file mode 100644 index 4a7353c..0000000 --- a/examples/resources/epilot-portal_portal_page/import.sh +++ /dev/null @@ -1 +0,0 @@ -terraform import epilot-portal_portal_page.my_epilot-portal_portal_page "5da0a718-c822-403d-9f5d-20d4584e0528" diff --git a/examples/resources/epilot-portal_portal_page/resource.tf b/examples/resources/epilot-portal_portal_page/resource.tf deleted file mode 100644 index 20879ea..0000000 --- a/examples/resources/epilot-portal_portal_page/resource.tf +++ /dev/null @@ -1,45 +0,0 @@ -resource "epilot-portal_portal_page" "my_portalpage" { - additional_properties = "{ \"see\": \"documentation\" }" - blocks = { - key = { - additional_properties = "{ \"see\": \"documentation\" }" - id = "c495fef9-eeca-4019-a989-8390dcd9825b" - order = 1 - parent_id = "c495fef9-eeca-4019-a989-8390dcd9825b" - props = { - additional_properties = "{ \"see\": \"documentation\" }" - content = { - key = jsonencode("value") - } - design = { - key = jsonencode("value") - } - visibility = { - key = jsonencode("value") - } - } - type = "tab" - } - } - content = { - key = jsonencode("value") - } - design = { - key = jsonencode("value") - } - domain = "customer-portal.epilot.io" - is_deleted = false - is_entry_route = false - is_public = true - is_system = false - order = 1 - parent_id = "c495fef9-eeca-4019-a989-8390dcd9825b" - path = "/dashboard" - schema = [ - "contract" - ] - slug = "dashboard" - visibility = { - key = jsonencode("value") - } -} \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 5ea134e..1d84a31 100644 --- a/gen.yaml +++ b/gen.yaml @@ -13,6 +13,9 @@ generation: auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false + hoistGlobalSecurity: true + schemas: + allOfMergeStrategy: shallowMerge tests: generateTests: true generateNewTests: false @@ -35,7 +38,7 @@ go: outputModelSuffix: output packageName: openapi terraform: - version: 0.25.16 + version: 0.26.0 additionalDataSources: [] additionalDependencies: {} additionalEphemeralResources: [] @@ -60,3 +63,4 @@ terraform: inputModelSuffix: input outputModelSuffix: output packageName: epilot-portal + unionDeserializationStrategy: populated-fields diff --git a/go.mod b/go.mod index 38e9ec6..8e06486 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,13 @@ module github.com/epilot-dev/terraform-provider-epilot-portal go 1.23.7 require ( - github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/terraform-plugin-docs v0.22.0 - github.com/hashicorp/terraform-plugin-framework v1.15.0 - github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 + github.com/hashicorp/terraform-plugin-framework v1.15.1 + github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 github.com/hashicorp/terraform-plugin-go v0.28.0 github.com/hashicorp/terraform-plugin-log v0.9.0 + github.com/stretchr/testify v1.8.3 ) require ( @@ -25,6 +24,7 @@ require ( github.com/bgentry/speakeasy v0.1.0 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect github.com/cloudflare/circl v1.6.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.16.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect @@ -52,6 +52,7 @@ require ( 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/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.0 // indirect diff --git a/go.sum b/go.sum index 039f01f..e91839d 100644 --- a/go.sum +++ b/go.sum @@ -33,8 +33,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05 h1:S92OBrGuLLZsyM5ybUzgc/mPjIYk2AZqufieooe98uw= -github.com/ericlagergren/decimal v0.0.0-20221120152707-495c53812d05/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= @@ -91,12 +89,10 @@ github.com/hashicorp/terraform-json v0.25.0 h1:rmNqc/CIfcWawGiwXmRuiXJKEiJu1ntGo github.com/hashicorp/terraform-json v0.25.0/go.mod h1:sMKS8fiRDX4rVlR6EJUMudg1WcanxCMoWwTLkgZP/vc= github.com/hashicorp/terraform-plugin-docs v0.22.0 h1:fwIDStbFel1PPNkM+mDPnpB4efHZBdGoMz/zt5FbTDw= github.com/hashicorp/terraform-plugin-docs v0.22.0/go.mod h1:55DJVyZ7BNK4t/lANcQ1YpemRuS6KsvIO1BbGA+xzGE= -github.com/hashicorp/terraform-plugin-framework v1.15.0 h1:LQ2rsOfmDLxcn5EeIwdXFtr03FVsNktbbBci8cOKdb4= -github.com/hashicorp/terraform-plugin-framework v1.15.0/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= -github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17554Kpt9jFXngdM6fXbnUnZ6iT2IeiYA= -github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0/go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E= -github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 h1:0uYQcqqgW3BMyyve07WJgpKorXST3zkpzvrOnf3mpbg= -github.com/hashicorp/terraform-plugin-framework-validators v0.17.0/go.mod h1:VwdfgE/5Zxm43flraNa0VjcvKQOGVrcO4X8peIri0T0= +github.com/hashicorp/terraform-plugin-framework v1.15.1 h1:2mKDkwb8rlx/tvJTlIcpw0ykcmvdWv+4gY3SIgk8Pq8= +github.com/hashicorp/terraform-plugin-framework v1.15.1/go.mod h1:hxrNI/GY32KPISpWqlCoTLM9JZsGH3CyYlir09bD/fI= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw= +github.com/hashicorp/terraform-plugin-framework-validators v0.18.0/go.mod h1:lZvZvagw5hsJwuY7mAY6KUz45/U6fiDR0CzQAwWD0CA= github.com/hashicorp/terraform-plugin-go v0.28.0 h1:zJmu2UDwhVN0J+J20RE5huiF3XXlTYVIleaevHZgKPA= github.com/hashicorp/terraform-plugin-go v0.28.0/go.mod h1:FDa2Bb3uumkTGSkTFpWSOwWJDwA7bf3vdP3ltLDTH6o= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= diff --git a/internal/provider/portalconfig_data_source.go b/internal/provider/portalconfig_data_source.go deleted file mode 100644 index 6812a14..0000000 --- a/internal/provider/portalconfig_data_source.go +++ /dev/null @@ -1,697 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "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 = &PortalConfigDataSource{} -var _ datasource.DataSourceWithConfigure = &PortalConfigDataSource{} - -func NewPortalConfigDataSource() datasource.DataSource { - return &PortalConfigDataSource{} -} - -// PortalConfigDataSource is the data source implementation. -type PortalConfigDataSource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// PortalConfigDataSourceModel describes the data model. -type PortalConfigDataSourceModel struct { - AccessToken types.String `tfsdk:"access_token"` - AdvancedMfa *tfTypes.UpsertPortalConfigV3AdvancedMfa `tfsdk:"advanced_mfa"` - AllowedFileExtensions *tfTypes.AllowedFileExtensions `tfsdk:"allowed_file_extensions"` - ApprovalStateAttributes jsontypes.Normalized `tfsdk:"approval_state_attributes"` - AuthSettings *tfTypes.UpsertPortalConfigV3AuthSettings `tfsdk:"auth_settings"` - CognitoDetails *tfTypes.UpsertPortalConfigV3CognitoDetails `tfsdk:"cognito_details"` - Config types.String `tfsdk:"config"` - ContactIdentifiers []types.String `tfsdk:"contact_identifiers"` - ContractIdentifiers jsontypes.Normalized `tfsdk:"contract_identifiers"` - ContractSelectorConfig *tfTypes.UpsertPortalConfigV3ContractSelectorConfig `tfsdk:"contract_selector_config"` - DefaultUserToNotify *tfTypes.UpsertPortalConfigV3DefaultUserToNotify `tfsdk:"default_user_to_notify"` - DesignID types.String `tfsdk:"design_id"` - Domain types.String `tfsdk:"domain"` - EmailTemplates *tfTypes.EmailTemplates `tfsdk:"email_templates"` - Enabled types.Bool `tfsdk:"enabled"` - EntityActions []tfTypes.EntityActions `tfsdk:"entity_actions"` - EntityEditRules jsontypes.Normalized `tfsdk:"entity_edit_rules"` - EntityIdentifiers *tfTypes.UpsertPortalConfigV3EntityIdentifiers `tfsdk:"entity_identifiers"` - ExtensionHooks map[string]tfTypes.ExtensionHookConfig `tfsdk:"extension_hooks"` - Extensions []tfTypes.ExtensionConfig `tfsdk:"extensions"` - FeatureFlags jsontypes.Normalized `tfsdk:"feature_flags"` - FeatureSettings *tfTypes.UpsertPortalConfigV3FeatureSettings `tfsdk:"feature_settings"` - Grants jsontypes.Normalized `tfsdk:"grants"` - IdentityProviders jsontypes.Normalized `tfsdk:"identity_providers"` - Images *tfTypes.UpsertPortalConfigV3Images `tfsdk:"images"` - InactiveContractCutoffYears types.Float64 `tfsdk:"inactive_contract_cutoff_years"` - IsDummy types.Bool `tfsdk:"is_dummy"` - IsEpilotDomain types.Bool `tfsdk:"is_epilot_domain"` - IsV3Item types.Bool `tfsdk:"is_v3_item"` - MeterReadingGracePeriod types.Float64 `tfsdk:"meter_reading_grace_period"` - Name types.String `tfsdk:"name"` - OrgSettings *tfTypes.PortalConfigV3OrgSettings `tfsdk:"org_settings"` - OrganizationID types.String `tfsdk:"organization_id"` - Origin types.String `tfsdk:"origin"` - Pages jsontypes.Normalized `tfsdk:"pages"` - PortalID types.String `tfsdk:"portal_id"` - PortalSkV3 types.String `tfsdk:"portal_sk_v3"` - PreventSearchEngineIndexing types.Bool `tfsdk:"prevent_search_engine_indexing"` - RegistrationIdentifiers jsontypes.Normalized `tfsdk:"registration_identifiers"` - SelfRegistrationSetting types.String `tfsdk:"self_registration_setting"` - TriggeredJourneys []tfTypes.PortalConfigV3TriggeredJourneys `tfsdk:"triggered_journeys"` -} - -// Metadata returns the data source type name. -func (r *PortalConfigDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_portal_config" -} - -// Schema defines the schema for the data source. -func (r *PortalConfigDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "PortalConfig DataSource", - - Attributes: map[string]schema.Attribute{ - "access_token": schema.StringAttribute{ - Computed: true, - Description: `Access token for the portal`, - }, - "advanced_mfa": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Advanced MFA feature flag`, - }, - }, - }, - "allowed_file_extensions": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "archive": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "audio_video": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "cad": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "calendar": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "document": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "email": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "image": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "other": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "presentation": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "spreadsheet": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Allowed file extensions for upload`, - }, - "approval_state_attributes": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "auth_settings": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "auto_redirect_to_sso": schema.BoolAttribute{ - Computed: true, - Description: `Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page.`, - }, - "entry_point": schema.StringAttribute{ - Computed: true, - }, - "passwordless_login": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Passwordless login feature flag`, - }, - }, - }, - "preferred_sso_providers": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - Description: `Authentication settings for the portal`, - }, - "cognito_details": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "cognito_user_pool_arn": schema.StringAttribute{ - Computed: true, - Description: `Cognito user pool ARN`, - }, - "cognito_user_pool_client_id": schema.StringAttribute{ - Computed: true, - Description: `Cognito user pool client ID`, - }, - "cognito_user_pool_id": schema.StringAttribute{ - Computed: true, - Description: `Cognito user pool ID`, - }, - "password_policy": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "minimum_length": schema.Int64Attribute{ - Computed: true, - Description: `Minimum password length`, - }, - "require_lowercase": schema.BoolAttribute{ - Computed: true, - Description: `Require lowercase characters`, - }, - "require_numbers": schema.BoolAttribute{ - Computed: true, - Description: `Require numbers`, - }, - "require_symbols": schema.BoolAttribute{ - Computed: true, - Description: `Require symbols`, - }, - "require_uppercase": schema.BoolAttribute{ - Computed: true, - Description: `Require uppercase characters`, - }, - }, - Description: `Password policy for the portal`, - }, - }, - Description: `AWS Cognito Pool details for the portal`, - }, - "config": schema.StringAttribute{ - Computed: true, - Description: `Stringified object with configuration details`, - }, - "contact_identifiers": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `Deprecated. Use registration_identifiers instead.`, - }, - "contract_identifiers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Identifiers to identify a contract by a portal user. Parsed as JSON.`, - }, - "contract_selector_config": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "show_inactive": schema.BoolAttribute{ - Computed: true, - Description: `Whether to show inactive contracts in the selector`, - }, - "title_path": schema.StringAttribute{ - Computed: true, - Description: `Path to the property to use as the contract title`, - }, - }, - Description: `Configuration for contract selector in the portal`, - }, - "default_user_to_notify": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "on_pending_user": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "display_name": schema.StringAttribute{ - Computed: true, - }, - "email": schema.StringAttribute{ - Computed: true, - }, - "image_uri": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "key": schema.StringAttribute{ - Computed: true, - }, - "original": schema.StringAttribute{ - Computed: true, - }, - "thumbnail_32": schema.StringAttribute{ - Computed: true, - }, - "thumbnail_64": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "org_id": schema.StringAttribute{ - Computed: true, - }, - "phone": schema.StringAttribute{ - Computed: true, - }, - "type": schema.StringAttribute{ - Computed: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - }, - }, - }, - Description: `Default admin users for pending user notification to notify`, - }, - }, - Description: `Default 360 user to notify upon an internal notification`, - }, - "design_id": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "domain": schema.StringAttribute{ - Computed: true, - Description: `The URL on which the portal is accessible`, - }, - "email_templates": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "advanced_auth": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "advanced_mfa": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "confirm_account": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "confirm_email_update": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "forgot_password": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "invitation": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "journey_login_otp": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "journey_sign_in_one_time_password": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "journey_sign_up": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "on_doc_upload": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "on_map_a_pending_user": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "on_new_quote": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "on_workflow_step_assigned": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "verify_code_to_set_password": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - }, - Description: `Email templates used for authentication and internal processes`, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Enable/Disable the portal access`, - }, - "entity_actions": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "action_label": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "de": schema.StringAttribute{ - Computed: true, - }, - "en": schema.StringAttribute{ - Computed: true, - }, - }, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "slug": schema.StringAttribute{ - Computed: true, - Description: `URL-friendly identifier for the entity schema`, - }, - }, - }, - Description: `Journey actions allowed on an entity by a portal user`, - }, - "entity_edit_rules": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Rules for editing an entity by a portal user. Parsed as JSON.`, - }, - "entity_identifiers": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "type": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "attributes": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Attributes used to identify an entity`, - }, - "is_enabled": schema.BoolAttribute{ - Computed: true, - Description: `Enable/Disable the entity identifier`, - }, - }, - }, - }, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead.`, - }, - "extension_hooks": schema.MapNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "app_id": schema.StringAttribute{ - Computed: true, - Description: `The ID of the app that is being hooked into.`, - }, - "hook_id": schema.StringAttribute{ - Computed: true, - Description: `The ID of the hook that is being configured.`, - }, - }, - }, - Description: `Configured Portal extensions hooks`, - }, - "extensions": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Description: `Name of the extension`, - }, - "options": schema.MapAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Extension option values.`, - }, - "status": schema.StringAttribute{ - Computed: true, - Description: `Status of the extension`, - }, - }, - }, - Description: `Configured Portal extensions`, - }, - "feature_flags": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Feature flags for the portal. Parsed as JSON.`, - }, - "feature_settings": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "billing": schema.BoolAttribute{ - Computed: true, - Description: `Billing feature flag`, - }, - "change_due_date": schema.BoolAttribute{ - Computed: true, - Description: `Change due date feature flag`, - }, - "new_design": schema.BoolAttribute{ - Computed: true, - Description: `Enable or disable the new design for the portal`, - }, - "start_page": schema.BoolAttribute{ - Computed: true, - Description: `Start page feature flag`, - }, - }, - Description: `Feature settings for the portal`, - }, - "grants": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Permissions granted to a portal user while accessing entities. Parsed as JSON.`, - }, - "identity_providers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "images": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "order_left_teaser": schema.StringAttribute{ - Computed: true, - Description: `URL of the order left teaser image`, - }, - "order_right_teaser": schema.StringAttribute{ - Computed: true, - Description: `URL of the order right teaser image`, - }, - "welcome_banner": schema.StringAttribute{ - Computed: true, - Description: `URL of the welcome banner image`, - }, - }, - Description: `Teaser & Banner Image web links`, - }, - "inactive_contract_cutoff_years": schema.Float64Attribute{ - Computed: true, - Description: `Number of years to look back for showing inactive contracts in the portal`, - }, - "is_dummy": schema.BoolAttribute{ - Computed: true, - Description: `Whether this is a dummy/test portal configuration`, - }, - "is_epilot_domain": schema.BoolAttribute{ - Computed: true, - Description: `Mark true if the domain is an Epilot domain`, - }, - "is_v3_item": schema.BoolAttribute{ - Computed: true, - Description: `Whether this is a v3 portal configuration`, - }, - "meter_reading_grace_period": schema.Float64Attribute{ - Computed: true, - Description: `Grace period in days for meter readings`, - }, - "name": schema.StringAttribute{ - Computed: true, - Description: `A short name to identify your portal`, - }, - "org_settings": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "canary": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Enable/Disable the canary feature`, - }, - }, - Description: `Canary feature flag`, - }, - "notracking": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Disable browser-side scripts that track advanced usage metrics`, - }, - }, - Description: `Disable Advanced Usage Metrics`, - }, - }, - Description: `Organization settings`, - }, - "organization_id": schema.StringAttribute{ - Computed: true, - Description: `ID of the organization`, - }, - "origin": schema.StringAttribute{ - Computed: true, - Description: `Origin of the portal`, - }, - "pages": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "portal_id": schema.StringAttribute{ - Required: true, - Description: `Portal ID (readonly UUID generated on portal creation)`, - }, - "portal_sk_v3": schema.StringAttribute{ - Computed: true, - Description: `Key of the portal config`, - }, - "prevent_search_engine_indexing": schema.BoolAttribute{ - Computed: true, - Description: `Prevent indexing by search engines`, - }, - "registration_identifiers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Identifiers to identify a contact of a portal user during the registration. Parsed as JSON.`, - }, - "self_registration_setting": schema.StringAttribute{ - Computed: true, - }, - "triggered_journeys": schema.ListNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "journey_id": schema.StringAttribute{ - Computed: true, - Description: `Entity ID`, - }, - "trigger_name": schema.StringAttribute{ - Computed: true, - }, - }, - }, - Description: `Journeys automatically opened on a portal user action`, - }, - }, - } -} - -func (r *PortalConfigDataSource) 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 *PortalConfigDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *PortalConfigDataSourceModel - 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 - } - - request, requestDiags := data.ToOperationsGetPortalConfigV3Request(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.GetPortalConfigV3(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.PortalConfigV3 != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPortalConfigV3(ctx, res.PortalConfigV3)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/portalconfig_data_source_sdk.go b/internal/provider/portalconfig_data_source_sdk.go deleted file mode 100644 index 243b9d1..0000000 --- a/internal/provider/portalconfig_data_source_sdk.go +++ /dev/null @@ -1,373 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *PortalConfigDataSourceModel) RefreshFromSharedPortalConfigV3(ctx context.Context, resp *shared.PortalConfigV3) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AccessToken = types.StringPointerValue(resp.AccessToken) - if resp.AdvancedMfa == nil { - r.AdvancedMfa = nil - } else { - r.AdvancedMfa = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.AdvancedMfa.Enabled = types.BoolPointerValue(resp.AdvancedMfa.Enabled) - } - if resp.AllowedFileExtensions == nil { - r.AllowedFileExtensions = nil - } else { - r.AllowedFileExtensions = &tfTypes.AllowedFileExtensions{} - r.AllowedFileExtensions.Archive = make([]types.String, 0, len(resp.AllowedFileExtensions.Archive)) - for _, v := range resp.AllowedFileExtensions.Archive { - r.AllowedFileExtensions.Archive = append(r.AllowedFileExtensions.Archive, types.StringValue(v)) - } - r.AllowedFileExtensions.AudioVideo = make([]types.String, 0, len(resp.AllowedFileExtensions.AudioVideo)) - for _, v := range resp.AllowedFileExtensions.AudioVideo { - r.AllowedFileExtensions.AudioVideo = append(r.AllowedFileExtensions.AudioVideo, types.StringValue(v)) - } - r.AllowedFileExtensions.Cad = make([]types.String, 0, len(resp.AllowedFileExtensions.Cad)) - for _, v := range resp.AllowedFileExtensions.Cad { - r.AllowedFileExtensions.Cad = append(r.AllowedFileExtensions.Cad, types.StringValue(v)) - } - r.AllowedFileExtensions.Calendar = make([]types.String, 0, len(resp.AllowedFileExtensions.Calendar)) - for _, v := range resp.AllowedFileExtensions.Calendar { - r.AllowedFileExtensions.Calendar = append(r.AllowedFileExtensions.Calendar, types.StringValue(v)) - } - r.AllowedFileExtensions.Document = make([]types.String, 0, len(resp.AllowedFileExtensions.Document)) - for _, v := range resp.AllowedFileExtensions.Document { - r.AllowedFileExtensions.Document = append(r.AllowedFileExtensions.Document, types.StringValue(v)) - } - r.AllowedFileExtensions.Email = make([]types.String, 0, len(resp.AllowedFileExtensions.Email)) - for _, v := range resp.AllowedFileExtensions.Email { - r.AllowedFileExtensions.Email = append(r.AllowedFileExtensions.Email, types.StringValue(v)) - } - r.AllowedFileExtensions.Image = make([]types.String, 0, len(resp.AllowedFileExtensions.Image)) - for _, v := range resp.AllowedFileExtensions.Image { - r.AllowedFileExtensions.Image = append(r.AllowedFileExtensions.Image, types.StringValue(v)) - } - r.AllowedFileExtensions.Other = make([]types.String, 0, len(resp.AllowedFileExtensions.Other)) - for _, v := range resp.AllowedFileExtensions.Other { - r.AllowedFileExtensions.Other = append(r.AllowedFileExtensions.Other, types.StringValue(v)) - } - r.AllowedFileExtensions.Presentation = make([]types.String, 0, len(resp.AllowedFileExtensions.Presentation)) - for _, v := range resp.AllowedFileExtensions.Presentation { - r.AllowedFileExtensions.Presentation = append(r.AllowedFileExtensions.Presentation, types.StringValue(v)) - } - r.AllowedFileExtensions.Spreadsheet = make([]types.String, 0, len(resp.AllowedFileExtensions.Spreadsheet)) - for _, v := range resp.AllowedFileExtensions.Spreadsheet { - r.AllowedFileExtensions.Spreadsheet = append(r.AllowedFileExtensions.Spreadsheet, types.StringValue(v)) - } - } - if resp.ApprovalStateAttributes == nil { - r.ApprovalStateAttributes = jsontypes.NewNormalizedNull() - } else { - approvalStateAttributesResult, _ := json.Marshal(resp.ApprovalStateAttributes) - r.ApprovalStateAttributes = jsontypes.NewNormalizedValue(string(approvalStateAttributesResult)) - } - if resp.AuthSettings == nil { - r.AuthSettings = nil - } else { - r.AuthSettings = &tfTypes.UpsertPortalConfigV3AuthSettings{} - r.AuthSettings.AutoRedirectToSso = types.BoolPointerValue(resp.AuthSettings.AutoRedirectToSso) - if resp.AuthSettings.EntryPoint != nil { - r.AuthSettings.EntryPoint = types.StringValue(string(*resp.AuthSettings.EntryPoint)) - } else { - r.AuthSettings.EntryPoint = types.StringNull() - } - if resp.AuthSettings.PasswordlessLogin == nil { - r.AuthSettings.PasswordlessLogin = nil - } else { - r.AuthSettings.PasswordlessLogin = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.AuthSettings.PasswordlessLogin.Enabled = types.BoolPointerValue(resp.AuthSettings.PasswordlessLogin.Enabled) - } - r.AuthSettings.PreferredSsoProviders = make([]types.String, 0, len(resp.AuthSettings.PreferredSsoProviders)) - for _, v := range resp.AuthSettings.PreferredSsoProviders { - r.AuthSettings.PreferredSsoProviders = append(r.AuthSettings.PreferredSsoProviders, types.StringValue(v)) - } - } - if resp.CognitoDetails == nil { - r.CognitoDetails = nil - } else { - r.CognitoDetails = &tfTypes.UpsertPortalConfigV3CognitoDetails{} - r.CognitoDetails.CognitoUserPoolArn = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolArn) - r.CognitoDetails.CognitoUserPoolClientID = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolClientID) - r.CognitoDetails.CognitoUserPoolID = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolID) - if resp.CognitoDetails.PasswordPolicy == nil { - r.CognitoDetails.PasswordPolicy = nil - } else { - r.CognitoDetails.PasswordPolicy = &tfTypes.UpsertPortalConfigV3PasswordPolicy{} - r.CognitoDetails.PasswordPolicy.MinimumLength = types.Int64PointerValue(resp.CognitoDetails.PasswordPolicy.MinimumLength) - r.CognitoDetails.PasswordPolicy.RequireLowercase = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireLowercase) - r.CognitoDetails.PasswordPolicy.RequireNumbers = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireNumbers) - r.CognitoDetails.PasswordPolicy.RequireSymbols = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireSymbols) - r.CognitoDetails.PasswordPolicy.RequireUppercase = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireUppercase) - } - } - r.Config = types.StringPointerValue(resp.Config) - r.ContactIdentifiers = make([]types.String, 0, len(resp.ContactIdentifiers)) - for _, v := range resp.ContactIdentifiers { - r.ContactIdentifiers = append(r.ContactIdentifiers, types.StringValue(v)) - } - if resp.ContractIdentifiers == nil { - r.ContractIdentifiers = jsontypes.NewNormalizedNull() - } else { - contractIdentifiersResult, _ := json.Marshal(resp.ContractIdentifiers) - r.ContractIdentifiers = jsontypes.NewNormalizedValue(string(contractIdentifiersResult)) - } - if resp.ContractSelectorConfig == nil { - r.ContractSelectorConfig = nil - } else { - r.ContractSelectorConfig = &tfTypes.UpsertPortalConfigV3ContractSelectorConfig{} - r.ContractSelectorConfig.ShowInactive = types.BoolPointerValue(resp.ContractSelectorConfig.ShowInactive) - r.ContractSelectorConfig.TitlePath = types.StringPointerValue(resp.ContractSelectorConfig.TitlePath) - } - if resp.DefaultUserToNotify == nil { - r.DefaultUserToNotify = nil - } else { - r.DefaultUserToNotify = &tfTypes.UpsertPortalConfigV3DefaultUserToNotify{} - r.DefaultUserToNotify.OnPendingUser = []tfTypes.AdminUser{} - - for _, onPendingUserItem := range resp.DefaultUserToNotify.OnPendingUser { - var onPendingUser tfTypes.AdminUser - - if onPendingUserItem.AdditionalProperties == nil { - onPendingUser.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult, _ := json.Marshal(onPendingUserItem.AdditionalProperties) - onPendingUser.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult)) - } - onPendingUser.DisplayName = types.StringPointerValue(onPendingUserItem.DisplayName) - onPendingUser.Email = types.StringPointerValue(onPendingUserItem.Email) - if onPendingUserItem.ImageURI == nil { - onPendingUser.ImageURI = nil - } else { - onPendingUser.ImageURI = &tfTypes.ImageURI{} - onPendingUser.ImageURI.Key = types.StringPointerValue(onPendingUserItem.ImageURI.Key) - onPendingUser.ImageURI.Original = types.StringPointerValue(onPendingUserItem.ImageURI.Original) - onPendingUser.ImageURI.Thumbnail32 = types.StringPointerValue(onPendingUserItem.ImageURI.Thumbnail32) - onPendingUser.ImageURI.Thumbnail64 = types.StringPointerValue(onPendingUserItem.ImageURI.Thumbnail64) - } - onPendingUser.OrgID = types.StringPointerValue(onPendingUserItem.OrgID) - onPendingUser.Phone = types.StringPointerValue(onPendingUserItem.Phone) - onPendingUser.Type = types.StringPointerValue(onPendingUserItem.Type) - onPendingUser.UserID = types.StringPointerValue(onPendingUserItem.UserID) - - r.DefaultUserToNotify.OnPendingUser = append(r.DefaultUserToNotify.OnPendingUser, onPendingUser) - } - } - r.DesignID = types.StringPointerValue(resp.DesignID) - r.Domain = types.StringPointerValue(resp.Domain) - if resp.EmailTemplates == nil { - r.EmailTemplates = nil - } else { - r.EmailTemplates = &tfTypes.EmailTemplates{} - r.EmailTemplates.AdvancedAuth = types.StringPointerValue(resp.EmailTemplates.AdvancedAuth) - r.EmailTemplates.AdvancedMFA = types.StringPointerValue(resp.EmailTemplates.AdvancedMFA) - r.EmailTemplates.ConfirmAccount = types.StringPointerValue(resp.EmailTemplates.ConfirmAccount) - r.EmailTemplates.ConfirmEmailUpdate = types.StringPointerValue(resp.EmailTemplates.ConfirmEmailUpdate) - r.EmailTemplates.ForgotPassword = types.StringPointerValue(resp.EmailTemplates.ForgotPassword) - r.EmailTemplates.Invitation = types.StringPointerValue(resp.EmailTemplates.Invitation) - r.EmailTemplates.JourneyLoginOTP = types.StringPointerValue(resp.EmailTemplates.JourneyLoginOTP) - r.EmailTemplates.JourneySignInOneTimePassword = types.StringPointerValue(resp.EmailTemplates.JourneySignInOneTimePassword) - r.EmailTemplates.JourneySignUp = types.StringPointerValue(resp.EmailTemplates.JourneySignUp) - r.EmailTemplates.OnDocUpload = types.StringPointerValue(resp.EmailTemplates.OnDocUpload) - r.EmailTemplates.OnMapAPendingUser = types.StringPointerValue(resp.EmailTemplates.OnMapAPendingUser) - r.EmailTemplates.OnNewQuote = types.StringPointerValue(resp.EmailTemplates.OnNewQuote) - r.EmailTemplates.OnWorkflowStepAssigned = types.StringPointerValue(resp.EmailTemplates.OnWorkflowStepAssigned) - r.EmailTemplates.VerifyCodeToSetPassword = types.StringPointerValue(resp.EmailTemplates.VerifyCodeToSetPassword) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.EntityActions = []tfTypes.EntityActions{} - - for _, entityActionsItem := range resp.EntityActions { - var entityActions tfTypes.EntityActions - - if entityActionsItem.ActionLabel == nil { - entityActions.ActionLabel = nil - } else { - entityActions.ActionLabel = &tfTypes.UpsertPortalConfigV3ActionLabel{} - entityActions.ActionLabel.De = types.StringPointerValue(entityActionsItem.ActionLabel.De) - entityActions.ActionLabel.En = types.StringPointerValue(entityActionsItem.ActionLabel.En) - } - entityActions.JourneyID = types.StringPointerValue(entityActionsItem.JourneyID) - if entityActionsItem.Slug != nil { - entityActions.Slug = types.StringValue(string(*entityActionsItem.Slug)) - } else { - entityActions.Slug = types.StringNull() - } - - r.EntityActions = append(r.EntityActions, entityActions) - } - if resp.EntityEditRules == nil { - r.EntityEditRules = jsontypes.NewNormalizedNull() - } else { - entityEditRulesResult, _ := json.Marshal(resp.EntityEditRules) - r.EntityEditRules = jsontypes.NewNormalizedValue(string(entityEditRulesResult)) - } - if resp.EntityIdentifiers == nil { - r.EntityIdentifiers = nil - } else { - r.EntityIdentifiers = &tfTypes.UpsertPortalConfigV3EntityIdentifiers{} - if resp.EntityIdentifiers.Type == nil { - r.EntityIdentifiers.Type = nil - } else { - r.EntityIdentifiers.Type = &tfTypes.UpsertPortalConfigV3Type{} - r.EntityIdentifiers.Type.Attributes = make([]types.String, 0, len(resp.EntityIdentifiers.Type.Attributes)) - for _, v := range resp.EntityIdentifiers.Type.Attributes { - r.EntityIdentifiers.Type.Attributes = append(r.EntityIdentifiers.Type.Attributes, types.StringValue(v)) - } - r.EntityIdentifiers.Type.IsEnabled = types.BoolPointerValue(resp.EntityIdentifiers.Type.IsEnabled) - } - } - if len(resp.ExtensionHooks) > 0 { - r.ExtensionHooks = make(map[string]tfTypes.ExtensionHookConfig, len(resp.ExtensionHooks)) - for extensionHookConfigKey, extensionHookConfigValue := range resp.ExtensionHooks { - var extensionHookConfigResult tfTypes.ExtensionHookConfig - extensionHookConfigResult.AppID = types.StringPointerValue(extensionHookConfigValue.AppID) - extensionHookConfigResult.HookID = types.StringPointerValue(extensionHookConfigValue.HookID) - - r.ExtensionHooks[extensionHookConfigKey] = extensionHookConfigResult - } - } - r.Extensions = []tfTypes.ExtensionConfig{} - - for _, extensionsItem := range resp.Extensions { - var extensions tfTypes.ExtensionConfig - - extensions.ID = types.StringValue(extensionsItem.ID) - if len(extensionsItem.Options) > 0 { - extensions.Options = make(map[string]types.String, len(extensionsItem.Options)) - for key, value := range extensionsItem.Options { - extensions.Options[key] = types.StringValue(value) - } - } - if extensionsItem.Status != nil { - extensions.Status = types.StringValue(string(*extensionsItem.Status)) - } else { - extensions.Status = types.StringNull() - } - - r.Extensions = append(r.Extensions, extensions) - } - if resp.FeatureFlags == nil { - r.FeatureFlags = jsontypes.NewNormalizedNull() - } else { - featureFlagsResult, _ := json.Marshal(resp.FeatureFlags) - r.FeatureFlags = jsontypes.NewNormalizedValue(string(featureFlagsResult)) - } - if resp.FeatureSettings == nil { - r.FeatureSettings = nil - } else { - r.FeatureSettings = &tfTypes.UpsertPortalConfigV3FeatureSettings{} - r.FeatureSettings.Billing = types.BoolPointerValue(resp.FeatureSettings.Billing) - r.FeatureSettings.ChangeDueDate = types.BoolPointerValue(resp.FeatureSettings.ChangeDueDate) - r.FeatureSettings.NewDesign = types.BoolPointerValue(resp.FeatureSettings.NewDesign) - r.FeatureSettings.StartPage = types.BoolPointerValue(resp.FeatureSettings.StartPage) - } - if resp.Grants == nil { - r.Grants = jsontypes.NewNormalizedNull() - } else { - grantsResult, _ := json.Marshal(resp.Grants) - r.Grants = jsontypes.NewNormalizedValue(string(grantsResult)) - } - if resp.IdentityProviders == nil { - r.IdentityProviders = jsontypes.NewNormalizedNull() - } else { - identityProvidersResult, _ := json.Marshal(resp.IdentityProviders) - r.IdentityProviders = jsontypes.NewNormalizedValue(string(identityProvidersResult)) - } - if resp.Images == nil { - r.Images = nil - } else { - r.Images = &tfTypes.UpsertPortalConfigV3Images{} - r.Images.OrderLeftTeaser = types.StringPointerValue(resp.Images.OrderLeftTeaser) - r.Images.OrderRightTeaser = types.StringPointerValue(resp.Images.OrderRightTeaser) - r.Images.WelcomeBanner = types.StringPointerValue(resp.Images.WelcomeBanner) - } - r.InactiveContractCutoffYears = types.Float64PointerValue(resp.InactiveContractCutoffYears) - r.IsDummy = types.BoolPointerValue(resp.IsDummy) - r.IsEpilotDomain = types.BoolPointerValue(resp.IsEpilotDomain) - r.IsV3Item = types.BoolPointerValue(resp.IsV3Item) - r.MeterReadingGracePeriod = types.Float64PointerValue(resp.MeterReadingGracePeriod) - r.Name = types.StringPointerValue(resp.Name) - if resp.OrgSettings == nil { - r.OrgSettings = nil - } else { - r.OrgSettings = &tfTypes.PortalConfigV3OrgSettings{} - if resp.OrgSettings.Canary == nil { - r.OrgSettings.Canary = nil - } else { - r.OrgSettings.Canary = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.OrgSettings.Canary.Enabled = types.BoolPointerValue(resp.OrgSettings.Canary.Enabled) - } - if resp.OrgSettings.Notracking == nil { - r.OrgSettings.Notracking = nil - } else { - r.OrgSettings.Notracking = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.OrgSettings.Notracking.Enabled = types.BoolPointerValue(resp.OrgSettings.Notracking.Enabled) - } - } - r.OrganizationID = types.StringPointerValue(resp.OrganizationID) - r.Origin = types.StringPointerValue(resp.Origin) - if resp.Pages == nil { - r.Pages = jsontypes.NewNormalizedNull() - } else { - pagesResult, _ := json.Marshal(resp.Pages) - r.Pages = jsontypes.NewNormalizedValue(string(pagesResult)) - } - r.PortalID = types.StringPointerValue(resp.PortalID) - r.PortalSkV3 = types.StringPointerValue(resp.PortalSkV3) - r.PreventSearchEngineIndexing = types.BoolPointerValue(resp.PreventSearchEngineIndexing) - if resp.RegistrationIdentifiers == nil { - r.RegistrationIdentifiers = jsontypes.NewNormalizedNull() - } else { - registrationIdentifiersResult, _ := json.Marshal(resp.RegistrationIdentifiers) - r.RegistrationIdentifiers = jsontypes.NewNormalizedValue(string(registrationIdentifiersResult)) - } - if resp.SelfRegistrationSetting != nil { - r.SelfRegistrationSetting = types.StringValue(string(*resp.SelfRegistrationSetting)) - } else { - r.SelfRegistrationSetting = types.StringNull() - } - r.TriggeredJourneys = []tfTypes.PortalConfigV3TriggeredJourneys{} - - for _, triggeredJourneysItem := range resp.TriggeredJourneys { - var triggeredJourneys tfTypes.PortalConfigV3TriggeredJourneys - - triggeredJourneys.JourneyID = types.StringPointerValue(triggeredJourneysItem.JourneyID) - if triggeredJourneysItem.TriggerName != nil { - triggeredJourneys.TriggerName = types.StringValue(string(*triggeredJourneysItem.TriggerName)) - } else { - triggeredJourneys.TriggerName = types.StringNull() - } - - r.TriggeredJourneys = append(r.TriggeredJourneys, triggeredJourneys) - } - } - - return diags -} - -func (r *PortalConfigDataSourceModel) ToOperationsGetPortalConfigV3Request(ctx context.Context) (*operations.GetPortalConfigV3Request, diag.Diagnostics) { - var diags diag.Diagnostics - - var portalID string - portalID = r.PortalID.ValueString() - - out := operations.GetPortalConfigV3Request{ - PortalID: portalID, - } - - return &out, diags -} diff --git a/internal/provider/portalconfig_resource.go b/internal/provider/portalconfig_resource.go deleted file mode 100644 index 1439d1f..0000000 --- a/internal/provider/portalconfig_resource.go +++ /dev/null @@ -1,1040 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk" - speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators/objectvalidators" - speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators/stringvalidators" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" - "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 _ resource.Resource = &PortalConfigResource{} -var _ resource.ResourceWithImportState = &PortalConfigResource{} - -func NewPortalConfigResource() resource.Resource { - return &PortalConfigResource{} -} - -// PortalConfigResource defines the resource implementation. -type PortalConfigResource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// PortalConfigResourceModel describes the resource data model. -type PortalConfigResourceModel struct { - AccessToken types.String `tfsdk:"access_token"` - AdvancedMfa *tfTypes.UpsertPortalConfigV3AdvancedMfa `tfsdk:"advanced_mfa"` - AllowedFileExtensions *tfTypes.AllowedFileExtensions `tfsdk:"allowed_file_extensions"` - ApprovalStateAttributes jsontypes.Normalized `tfsdk:"approval_state_attributes"` - AuthSettings *tfTypes.UpsertPortalConfigV3AuthSettings `tfsdk:"auth_settings"` - CognitoDetails *tfTypes.UpsertPortalConfigV3CognitoDetails `tfsdk:"cognito_details"` - Config types.String `tfsdk:"config"` - ContactIdentifiers []types.String `tfsdk:"contact_identifiers"` - ContractIdentifiers jsontypes.Normalized `tfsdk:"contract_identifiers"` - ContractSelectorConfig *tfTypes.UpsertPortalConfigV3ContractSelectorConfig `tfsdk:"contract_selector_config"` - DefaultUserToNotify *tfTypes.UpsertPortalConfigV3DefaultUserToNotify `tfsdk:"default_user_to_notify"` - DesignID types.String `tfsdk:"design_id"` - Domain types.String `tfsdk:"domain"` - EmailTemplates *tfTypes.EmailTemplates `tfsdk:"email_templates"` - Enabled types.Bool `tfsdk:"enabled"` - EntityActions []tfTypes.EntityActions `tfsdk:"entity_actions"` - EntityEditRules jsontypes.Normalized `tfsdk:"entity_edit_rules"` - EntityIdentifiers *tfTypes.UpsertPortalConfigV3EntityIdentifiers `tfsdk:"entity_identifiers"` - ExtensionHooks map[string]tfTypes.ExtensionHookConfig `tfsdk:"extension_hooks"` - Extensions []tfTypes.ExtensionConfig `tfsdk:"extensions"` - FeatureFlags jsontypes.Normalized `tfsdk:"feature_flags"` - FeatureSettings *tfTypes.UpsertPortalConfigV3FeatureSettings `tfsdk:"feature_settings"` - Grants jsontypes.Normalized `tfsdk:"grants"` - IdentityProviders jsontypes.Normalized `tfsdk:"identity_providers"` - Images *tfTypes.UpsertPortalConfigV3Images `tfsdk:"images"` - InactiveContractCutoffYears types.Float64 `tfsdk:"inactive_contract_cutoff_years"` - IsDummy types.Bool `tfsdk:"is_dummy"` - IsEpilotDomain types.Bool `tfsdk:"is_epilot_domain"` - IsV3Item types.Bool `tfsdk:"is_v3_item"` - MeterReadingGracePeriod types.Float64 `tfsdk:"meter_reading_grace_period"` - Name types.String `tfsdk:"name"` - OrgSettings *tfTypes.PortalConfigV3OrgSettings `tfsdk:"org_settings"` - OrganizationID types.String `tfsdk:"organization_id"` - Origin types.String `tfsdk:"origin"` - Pages jsontypes.Normalized `tfsdk:"pages"` - PortalID types.String `tfsdk:"portal_id"` - PortalSkV3 types.String `tfsdk:"portal_sk_v3"` - PreventSearchEngineIndexing types.Bool `tfsdk:"prevent_search_engine_indexing"` - RegistrationIdentifiers jsontypes.Normalized `tfsdk:"registration_identifiers"` - SelfRegistrationSetting types.String `tfsdk:"self_registration_setting"` - TriggeredJourneys []tfTypes.PortalConfigV3TriggeredJourneys `tfsdk:"triggered_journeys"` -} - -func (r *PortalConfigResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_portal_config" -} - -func (r *PortalConfigResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "PortalConfig Resource", - Attributes: map[string]schema.Attribute{ - "access_token": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Access token for the portal`, - }, - "advanced_mfa": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Advanced MFA feature flag`, - }, - }, - }, - "allowed_file_extensions": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "archive": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "audio_video": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "cad": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "calendar": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "document": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "email": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "image": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "other": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "presentation": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "spreadsheet": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - }, - Description: `Allowed file extensions for upload`, - }, - "approval_state_attributes": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "auth_settings": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "auto_redirect_to_sso": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page.`, - }, - "entry_point": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["PASSWORD", "SSO"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "PASSWORD", - "SSO", - ), - }, - }, - "passwordless_login": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Passwordless login feature flag`, - }, - }, - }, - "preferred_sso_providers": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - }, - Description: `Authentication settings for the portal`, - }, - "cognito_details": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "cognito_user_pool_arn": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Cognito user pool ARN`, - }, - "cognito_user_pool_client_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Cognito user pool client ID`, - }, - "cognito_user_pool_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Cognito user pool ID`, - }, - "password_policy": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "minimum_length": schema.Int64Attribute{ - Computed: true, - Optional: true, - Description: `Minimum password length`, - }, - "require_lowercase": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Require lowercase characters`, - }, - "require_numbers": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Require numbers`, - }, - "require_symbols": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Require symbols`, - }, - "require_uppercase": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Require uppercase characters`, - }, - }, - Description: `Password policy for the portal`, - }, - }, - Description: `AWS Cognito Pool details for the portal`, - }, - "config": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Stringified object with configuration details`, - }, - "contact_identifiers": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `Deprecated. Use registration_identifiers instead.`, - }, - "contract_identifiers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Identifiers to identify a contract by a portal user. Parsed as JSON.`, - }, - "contract_selector_config": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "show_inactive": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether to show inactive contracts in the selector`, - }, - "title_path": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Path to the property to use as the contract title`, - }, - }, - Description: `Configuration for contract selector in the portal`, - }, - "default_user_to_notify": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "on_pending_user": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "display_name": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "email": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "image_uri": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "key": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "original": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "thumbnail_32": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "thumbnail_64": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "org_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "phone": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "user_id": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - Description: `Default admin users for pending user notification to notify`, - }, - }, - Description: `Default 360 user to notify upon an internal notification`, - }, - "design_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "domain": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The URL on which the portal is accessible`, - }, - "email_templates": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "advanced_auth": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "advanced_mfa": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "confirm_account": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "confirm_email_update": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "forgot_password": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "invitation": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "journey_login_otp": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "journey_sign_in_one_time_password": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "journey_sign_up": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "on_doc_upload": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "on_map_a_pending_user": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "on_new_quote": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "on_workflow_step_assigned": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "verify_code_to_set_password": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - }, - Description: `Email templates used for authentication and internal processes`, - }, - "enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Enable/Disable the portal access`, - }, - "entity_actions": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "action_label": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "de": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - "en": schema.StringAttribute{ - Computed: true, - Optional: true, - }, - }, - }, - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "slug": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `URL-friendly identifier for the entity schema. must be one of ["contact", "contract", "file", "order", "opportunity", "product", "price", "meter", "meter_counter"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "contact", - "contract", - "file", - "order", - "opportunity", - "product", - "price", - "meter", - "meter_counter", - ), - }, - }, - }, - }, - Description: `Journey actions allowed on an entity by a portal user`, - }, - "entity_edit_rules": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Rules for editing an entity by a portal user. Parsed as JSON.`, - }, - "entity_identifiers": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "type": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "attributes": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Attributes used to identify an entity`, - }, - "is_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Enable/Disable the entity identifier`, - }, - }, - }, - }, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead.`, - }, - "extension_hooks": schema.MapNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "app_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The ID of the app that is being hooked into.`, - }, - "hook_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The ID of the hook that is being configured.`, - }, - }, - }, - Description: `Configured Portal extensions hooks`, - }, - "extensions": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Name of the extension. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - "options": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - Description: `Extension option values.`, - }, - "status": schema.StringAttribute{ - Computed: true, - Optional: true, - Default: stringdefault.StaticString(`installed`), - Description: `Status of the extension. Default: "installed"; must be one of ["installed", "enabled"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "installed", - "enabled", - ), - }, - }, - }, - }, - Description: `Configured Portal extensions`, - }, - "feature_flags": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Feature flags for the portal. Parsed as JSON.`, - }, - "feature_settings": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "billing": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Billing feature flag`, - }, - "change_due_date": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Change due date feature flag`, - }, - "new_design": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Enable or disable the new design for the portal`, - }, - "start_page": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Start page feature flag`, - }, - }, - Description: `Feature settings for the portal`, - }, - "grants": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Permissions granted to a portal user while accessing entities. Parsed as JSON.`, - }, - "identity_providers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "images": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "order_left_teaser": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `URL of the order left teaser image`, - }, - "order_right_teaser": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `URL of the order right teaser image`, - }, - "welcome_banner": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `URL of the welcome banner image`, - }, - }, - Description: `Teaser & Banner Image web links`, - }, - "inactive_contract_cutoff_years": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Number of years to look back for showing inactive contracts in the portal`, - }, - "is_dummy": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether this is a dummy/test portal configuration`, - }, - "is_epilot_domain": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Mark true if the domain is an Epilot domain`, - }, - "is_v3_item": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether this is a v3 portal configuration`, - }, - "meter_reading_grace_period": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `Grace period in days for meter readings`, - }, - "name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `A short name to identify your portal`, - }, - "org_settings": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "canary": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Enable/Disable the canary feature`, - }, - }, - Description: `Canary feature flag`, - }, - "notracking": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "enabled": schema.BoolAttribute{ - Computed: true, - Description: `Disable browser-side scripts that track advanced usage metrics`, - }, - }, - Description: `Disable Advanced Usage Metrics`, - }, - }, - Description: `Organization settings`, - }, - "organization_id": schema.StringAttribute{ - Computed: true, - Description: `ID of the organization`, - }, - "origin": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Origin of the portal`, - }, - "pages": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "portal_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `ID of the portal`, - }, - "portal_sk_v3": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Key of the portal config`, - }, - "prevent_search_engine_indexing": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Prevent indexing by search engines`, - }, - "registration_identifiers": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Identifiers to identify a contact of a portal user during the registration. Parsed as JSON.`, - }, - "self_registration_setting": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["ALLOW_WITH_CONTACT_CREATION", "ALLOW_WITHOUT_CONTACT_CREATION", "DENY"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "ALLOW_WITH_CONTACT_CREATION", - "ALLOW_WITHOUT_CONTACT_CREATION", - "DENY", - ), - }, - }, - "triggered_journeys": schema.ListNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "journey_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `Entity ID`, - }, - "trigger_name": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `must be one of ["FIRST_LOGIN", "ACCEPT_ORDER", "DECLINE_ORDER"]`, - Validators: []validator.String{ - stringvalidator.OneOf( - "FIRST_LOGIN", - "ACCEPT_ORDER", - "DECLINE_ORDER", - ), - }, - }, - }, - }, - Description: `Journeys automatically opened on a portal user action`, - }, - }, - } -} - -func (r *PortalConfigResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.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 Resource 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 *PortalConfigResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *PortalConfigResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToSharedUpsertPortalConfigV3(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.CreatePortalConfig(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 != 201 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - if !(res.PortalConfigV3 != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPortalConfigV3(ctx, res.PortalConfigV3)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalConfigResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *PortalConfigResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.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 - } - - request, requestDiags := data.ToOperationsGetPortalConfigV3Request(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.GetPortalConfigV3(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 == 404 { - resp.State.RemoveResource(ctx) - 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.PortalConfigV3 != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPortalConfigV3(ctx, res.PortalConfigV3)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalConfigResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *PortalConfigResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsPutPortalConfigRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.PutPortalConfig(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.PortalConfigV3 != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPortalConfigV3(ctx, res.PortalConfigV3)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalConfigResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *PortalConfigResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.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 - } - - request, requestDiags := data.ToOperationsDeletePortalConfigRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.DeletePortalConfig(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 != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *PortalConfigResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("portal_id"), req.ID)...) -} diff --git a/internal/provider/portalconfig_resource_sdk.go b/internal/provider/portalconfig_resource_sdk.go deleted file mode 100644 index 1cf6353..0000000 --- a/internal/provider/portalconfig_resource_sdk.go +++ /dev/null @@ -1,1931 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *PortalConfigResourceModel) RefreshFromSharedPortalConfigV3(ctx context.Context, resp *shared.PortalConfigV3) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - r.AccessToken = types.StringPointerValue(resp.AccessToken) - if resp.AdvancedMfa == nil { - r.AdvancedMfa = nil - } else { - r.AdvancedMfa = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.AdvancedMfa.Enabled = types.BoolPointerValue(resp.AdvancedMfa.Enabled) - } - if resp.AllowedFileExtensions == nil { - r.AllowedFileExtensions = nil - } else { - r.AllowedFileExtensions = &tfTypes.AllowedFileExtensions{} - r.AllowedFileExtensions.Archive = make([]types.String, 0, len(resp.AllowedFileExtensions.Archive)) - for _, v := range resp.AllowedFileExtensions.Archive { - r.AllowedFileExtensions.Archive = append(r.AllowedFileExtensions.Archive, types.StringValue(v)) - } - r.AllowedFileExtensions.AudioVideo = make([]types.String, 0, len(resp.AllowedFileExtensions.AudioVideo)) - for _, v := range resp.AllowedFileExtensions.AudioVideo { - r.AllowedFileExtensions.AudioVideo = append(r.AllowedFileExtensions.AudioVideo, types.StringValue(v)) - } - r.AllowedFileExtensions.Cad = make([]types.String, 0, len(resp.AllowedFileExtensions.Cad)) - for _, v := range resp.AllowedFileExtensions.Cad { - r.AllowedFileExtensions.Cad = append(r.AllowedFileExtensions.Cad, types.StringValue(v)) - } - r.AllowedFileExtensions.Calendar = make([]types.String, 0, len(resp.AllowedFileExtensions.Calendar)) - for _, v := range resp.AllowedFileExtensions.Calendar { - r.AllowedFileExtensions.Calendar = append(r.AllowedFileExtensions.Calendar, types.StringValue(v)) - } - r.AllowedFileExtensions.Document = make([]types.String, 0, len(resp.AllowedFileExtensions.Document)) - for _, v := range resp.AllowedFileExtensions.Document { - r.AllowedFileExtensions.Document = append(r.AllowedFileExtensions.Document, types.StringValue(v)) - } - r.AllowedFileExtensions.Email = make([]types.String, 0, len(resp.AllowedFileExtensions.Email)) - for _, v := range resp.AllowedFileExtensions.Email { - r.AllowedFileExtensions.Email = append(r.AllowedFileExtensions.Email, types.StringValue(v)) - } - r.AllowedFileExtensions.Image = make([]types.String, 0, len(resp.AllowedFileExtensions.Image)) - for _, v := range resp.AllowedFileExtensions.Image { - r.AllowedFileExtensions.Image = append(r.AllowedFileExtensions.Image, types.StringValue(v)) - } - r.AllowedFileExtensions.Other = make([]types.String, 0, len(resp.AllowedFileExtensions.Other)) - for _, v := range resp.AllowedFileExtensions.Other { - r.AllowedFileExtensions.Other = append(r.AllowedFileExtensions.Other, types.StringValue(v)) - } - r.AllowedFileExtensions.Presentation = make([]types.String, 0, len(resp.AllowedFileExtensions.Presentation)) - for _, v := range resp.AllowedFileExtensions.Presentation { - r.AllowedFileExtensions.Presentation = append(r.AllowedFileExtensions.Presentation, types.StringValue(v)) - } - r.AllowedFileExtensions.Spreadsheet = make([]types.String, 0, len(resp.AllowedFileExtensions.Spreadsheet)) - for _, v := range resp.AllowedFileExtensions.Spreadsheet { - r.AllowedFileExtensions.Spreadsheet = append(r.AllowedFileExtensions.Spreadsheet, types.StringValue(v)) - } - } - if resp.ApprovalStateAttributes == nil { - r.ApprovalStateAttributes = jsontypes.NewNormalizedNull() - } else { - approvalStateAttributesResult, _ := json.Marshal(resp.ApprovalStateAttributes) - r.ApprovalStateAttributes = jsontypes.NewNormalizedValue(string(approvalStateAttributesResult)) - } - if resp.AuthSettings == nil { - r.AuthSettings = nil - } else { - r.AuthSettings = &tfTypes.UpsertPortalConfigV3AuthSettings{} - r.AuthSettings.AutoRedirectToSso = types.BoolPointerValue(resp.AuthSettings.AutoRedirectToSso) - if resp.AuthSettings.EntryPoint != nil { - r.AuthSettings.EntryPoint = types.StringValue(string(*resp.AuthSettings.EntryPoint)) - } else { - r.AuthSettings.EntryPoint = types.StringNull() - } - if resp.AuthSettings.PasswordlessLogin == nil { - r.AuthSettings.PasswordlessLogin = nil - } else { - r.AuthSettings.PasswordlessLogin = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.AuthSettings.PasswordlessLogin.Enabled = types.BoolPointerValue(resp.AuthSettings.PasswordlessLogin.Enabled) - } - r.AuthSettings.PreferredSsoProviders = make([]types.String, 0, len(resp.AuthSettings.PreferredSsoProviders)) - for _, v := range resp.AuthSettings.PreferredSsoProviders { - r.AuthSettings.PreferredSsoProviders = append(r.AuthSettings.PreferredSsoProviders, types.StringValue(v)) - } - } - if resp.CognitoDetails == nil { - r.CognitoDetails = nil - } else { - r.CognitoDetails = &tfTypes.UpsertPortalConfigV3CognitoDetails{} - r.CognitoDetails.CognitoUserPoolArn = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolArn) - r.CognitoDetails.CognitoUserPoolClientID = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolClientID) - r.CognitoDetails.CognitoUserPoolID = types.StringPointerValue(resp.CognitoDetails.CognitoUserPoolID) - if resp.CognitoDetails.PasswordPolicy == nil { - r.CognitoDetails.PasswordPolicy = nil - } else { - r.CognitoDetails.PasswordPolicy = &tfTypes.UpsertPortalConfigV3PasswordPolicy{} - r.CognitoDetails.PasswordPolicy.MinimumLength = types.Int64PointerValue(resp.CognitoDetails.PasswordPolicy.MinimumLength) - r.CognitoDetails.PasswordPolicy.RequireLowercase = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireLowercase) - r.CognitoDetails.PasswordPolicy.RequireNumbers = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireNumbers) - r.CognitoDetails.PasswordPolicy.RequireSymbols = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireSymbols) - r.CognitoDetails.PasswordPolicy.RequireUppercase = types.BoolPointerValue(resp.CognitoDetails.PasswordPolicy.RequireUppercase) - } - } - r.Config = types.StringPointerValue(resp.Config) - r.ContactIdentifiers = make([]types.String, 0, len(resp.ContactIdentifiers)) - for _, v := range resp.ContactIdentifiers { - r.ContactIdentifiers = append(r.ContactIdentifiers, types.StringValue(v)) - } - if resp.ContractIdentifiers == nil { - r.ContractIdentifiers = jsontypes.NewNormalizedNull() - } else { - contractIdentifiersResult, _ := json.Marshal(resp.ContractIdentifiers) - r.ContractIdentifiers = jsontypes.NewNormalizedValue(string(contractIdentifiersResult)) - } - if resp.ContractSelectorConfig == nil { - r.ContractSelectorConfig = nil - } else { - r.ContractSelectorConfig = &tfTypes.UpsertPortalConfigV3ContractSelectorConfig{} - r.ContractSelectorConfig.ShowInactive = types.BoolPointerValue(resp.ContractSelectorConfig.ShowInactive) - r.ContractSelectorConfig.TitlePath = types.StringPointerValue(resp.ContractSelectorConfig.TitlePath) - } - if resp.DefaultUserToNotify == nil { - r.DefaultUserToNotify = nil - } else { - r.DefaultUserToNotify = &tfTypes.UpsertPortalConfigV3DefaultUserToNotify{} - r.DefaultUserToNotify.OnPendingUser = []tfTypes.AdminUser{} - - for _, onPendingUserItem := range resp.DefaultUserToNotify.OnPendingUser { - var onPendingUser tfTypes.AdminUser - - if onPendingUserItem.AdditionalProperties == nil { - onPendingUser.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult, _ := json.Marshal(onPendingUserItem.AdditionalProperties) - onPendingUser.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult)) - } - onPendingUser.DisplayName = types.StringPointerValue(onPendingUserItem.DisplayName) - onPendingUser.Email = types.StringPointerValue(onPendingUserItem.Email) - if onPendingUserItem.ImageURI == nil { - onPendingUser.ImageURI = nil - } else { - onPendingUser.ImageURI = &tfTypes.ImageURI{} - onPendingUser.ImageURI.Key = types.StringPointerValue(onPendingUserItem.ImageURI.Key) - onPendingUser.ImageURI.Original = types.StringPointerValue(onPendingUserItem.ImageURI.Original) - onPendingUser.ImageURI.Thumbnail32 = types.StringPointerValue(onPendingUserItem.ImageURI.Thumbnail32) - onPendingUser.ImageURI.Thumbnail64 = types.StringPointerValue(onPendingUserItem.ImageURI.Thumbnail64) - } - onPendingUser.OrgID = types.StringPointerValue(onPendingUserItem.OrgID) - onPendingUser.Phone = types.StringPointerValue(onPendingUserItem.Phone) - onPendingUser.Type = types.StringPointerValue(onPendingUserItem.Type) - onPendingUser.UserID = types.StringPointerValue(onPendingUserItem.UserID) - - r.DefaultUserToNotify.OnPendingUser = append(r.DefaultUserToNotify.OnPendingUser, onPendingUser) - } - } - r.DesignID = types.StringPointerValue(resp.DesignID) - r.Domain = types.StringPointerValue(resp.Domain) - if resp.EmailTemplates == nil { - r.EmailTemplates = nil - } else { - r.EmailTemplates = &tfTypes.EmailTemplates{} - r.EmailTemplates.AdvancedAuth = types.StringPointerValue(resp.EmailTemplates.AdvancedAuth) - r.EmailTemplates.AdvancedMFA = types.StringPointerValue(resp.EmailTemplates.AdvancedMFA) - r.EmailTemplates.ConfirmAccount = types.StringPointerValue(resp.EmailTemplates.ConfirmAccount) - r.EmailTemplates.ConfirmEmailUpdate = types.StringPointerValue(resp.EmailTemplates.ConfirmEmailUpdate) - r.EmailTemplates.ForgotPassword = types.StringPointerValue(resp.EmailTemplates.ForgotPassword) - r.EmailTemplates.Invitation = types.StringPointerValue(resp.EmailTemplates.Invitation) - r.EmailTemplates.JourneyLoginOTP = types.StringPointerValue(resp.EmailTemplates.JourneyLoginOTP) - r.EmailTemplates.JourneySignInOneTimePassword = types.StringPointerValue(resp.EmailTemplates.JourneySignInOneTimePassword) - r.EmailTemplates.JourneySignUp = types.StringPointerValue(resp.EmailTemplates.JourneySignUp) - r.EmailTemplates.OnDocUpload = types.StringPointerValue(resp.EmailTemplates.OnDocUpload) - r.EmailTemplates.OnMapAPendingUser = types.StringPointerValue(resp.EmailTemplates.OnMapAPendingUser) - r.EmailTemplates.OnNewQuote = types.StringPointerValue(resp.EmailTemplates.OnNewQuote) - r.EmailTemplates.OnWorkflowStepAssigned = types.StringPointerValue(resp.EmailTemplates.OnWorkflowStepAssigned) - r.EmailTemplates.VerifyCodeToSetPassword = types.StringPointerValue(resp.EmailTemplates.VerifyCodeToSetPassword) - } - r.Enabled = types.BoolPointerValue(resp.Enabled) - r.EntityActions = []tfTypes.EntityActions{} - - for _, entityActionsItem := range resp.EntityActions { - var entityActions tfTypes.EntityActions - - if entityActionsItem.ActionLabel == nil { - entityActions.ActionLabel = nil - } else { - entityActions.ActionLabel = &tfTypes.UpsertPortalConfigV3ActionLabel{} - entityActions.ActionLabel.De = types.StringPointerValue(entityActionsItem.ActionLabel.De) - entityActions.ActionLabel.En = types.StringPointerValue(entityActionsItem.ActionLabel.En) - } - entityActions.JourneyID = types.StringPointerValue(entityActionsItem.JourneyID) - if entityActionsItem.Slug != nil { - entityActions.Slug = types.StringValue(string(*entityActionsItem.Slug)) - } else { - entityActions.Slug = types.StringNull() - } - - r.EntityActions = append(r.EntityActions, entityActions) - } - if resp.EntityEditRules == nil { - r.EntityEditRules = jsontypes.NewNormalizedNull() - } else { - entityEditRulesResult, _ := json.Marshal(resp.EntityEditRules) - r.EntityEditRules = jsontypes.NewNormalizedValue(string(entityEditRulesResult)) - } - if resp.EntityIdentifiers == nil { - r.EntityIdentifiers = nil - } else { - r.EntityIdentifiers = &tfTypes.UpsertPortalConfigV3EntityIdentifiers{} - if resp.EntityIdentifiers.Type == nil { - r.EntityIdentifiers.Type = nil - } else { - r.EntityIdentifiers.Type = &tfTypes.UpsertPortalConfigV3Type{} - r.EntityIdentifiers.Type.Attributes = make([]types.String, 0, len(resp.EntityIdentifiers.Type.Attributes)) - for _, v := range resp.EntityIdentifiers.Type.Attributes { - r.EntityIdentifiers.Type.Attributes = append(r.EntityIdentifiers.Type.Attributes, types.StringValue(v)) - } - r.EntityIdentifiers.Type.IsEnabled = types.BoolPointerValue(resp.EntityIdentifiers.Type.IsEnabled) - } - } - if len(resp.ExtensionHooks) > 0 { - r.ExtensionHooks = make(map[string]tfTypes.ExtensionHookConfig, len(resp.ExtensionHooks)) - for extensionHookConfigKey, extensionHookConfigValue := range resp.ExtensionHooks { - var extensionHookConfigResult tfTypes.ExtensionHookConfig - extensionHookConfigResult.AppID = types.StringPointerValue(extensionHookConfigValue.AppID) - extensionHookConfigResult.HookID = types.StringPointerValue(extensionHookConfigValue.HookID) - - r.ExtensionHooks[extensionHookConfigKey] = extensionHookConfigResult - } - } - r.Extensions = []tfTypes.ExtensionConfig{} - - for _, extensionsItem := range resp.Extensions { - var extensions tfTypes.ExtensionConfig - - extensions.ID = types.StringValue(extensionsItem.ID) - if len(extensionsItem.Options) > 0 { - extensions.Options = make(map[string]types.String, len(extensionsItem.Options)) - for key, value := range extensionsItem.Options { - extensions.Options[key] = types.StringValue(value) - } - } - if extensionsItem.Status != nil { - extensions.Status = types.StringValue(string(*extensionsItem.Status)) - } else { - extensions.Status = types.StringNull() - } - - r.Extensions = append(r.Extensions, extensions) - } - if resp.FeatureFlags == nil { - r.FeatureFlags = jsontypes.NewNormalizedNull() - } else { - featureFlagsResult, _ := json.Marshal(resp.FeatureFlags) - r.FeatureFlags = jsontypes.NewNormalizedValue(string(featureFlagsResult)) - } - if resp.FeatureSettings == nil { - r.FeatureSettings = nil - } else { - r.FeatureSettings = &tfTypes.UpsertPortalConfigV3FeatureSettings{} - r.FeatureSettings.Billing = types.BoolPointerValue(resp.FeatureSettings.Billing) - r.FeatureSettings.ChangeDueDate = types.BoolPointerValue(resp.FeatureSettings.ChangeDueDate) - r.FeatureSettings.NewDesign = types.BoolPointerValue(resp.FeatureSettings.NewDesign) - r.FeatureSettings.StartPage = types.BoolPointerValue(resp.FeatureSettings.StartPage) - } - if resp.Grants == nil { - r.Grants = jsontypes.NewNormalizedNull() - } else { - grantsResult, _ := json.Marshal(resp.Grants) - r.Grants = jsontypes.NewNormalizedValue(string(grantsResult)) - } - if resp.IdentityProviders == nil { - r.IdentityProviders = jsontypes.NewNormalizedNull() - } else { - identityProvidersResult, _ := json.Marshal(resp.IdentityProviders) - r.IdentityProviders = jsontypes.NewNormalizedValue(string(identityProvidersResult)) - } - if resp.Images == nil { - r.Images = nil - } else { - r.Images = &tfTypes.UpsertPortalConfigV3Images{} - r.Images.OrderLeftTeaser = types.StringPointerValue(resp.Images.OrderLeftTeaser) - r.Images.OrderRightTeaser = types.StringPointerValue(resp.Images.OrderRightTeaser) - r.Images.WelcomeBanner = types.StringPointerValue(resp.Images.WelcomeBanner) - } - r.InactiveContractCutoffYears = types.Float64PointerValue(resp.InactiveContractCutoffYears) - r.IsDummy = types.BoolPointerValue(resp.IsDummy) - r.IsEpilotDomain = types.BoolPointerValue(resp.IsEpilotDomain) - r.IsV3Item = types.BoolPointerValue(resp.IsV3Item) - r.MeterReadingGracePeriod = types.Float64PointerValue(resp.MeterReadingGracePeriod) - r.Name = types.StringPointerValue(resp.Name) - if resp.OrgSettings == nil { - r.OrgSettings = nil - } else { - r.OrgSettings = &tfTypes.PortalConfigV3OrgSettings{} - if resp.OrgSettings.Canary == nil { - r.OrgSettings.Canary = nil - } else { - r.OrgSettings.Canary = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.OrgSettings.Canary.Enabled = types.BoolPointerValue(resp.OrgSettings.Canary.Enabled) - } - if resp.OrgSettings.Notracking == nil { - r.OrgSettings.Notracking = nil - } else { - r.OrgSettings.Notracking = &tfTypes.UpsertPortalConfigV3AdvancedMfa{} - r.OrgSettings.Notracking.Enabled = types.BoolPointerValue(resp.OrgSettings.Notracking.Enabled) - } - } - r.OrganizationID = types.StringPointerValue(resp.OrganizationID) - r.Origin = types.StringPointerValue(resp.Origin) - if resp.Pages == nil { - r.Pages = jsontypes.NewNormalizedNull() - } else { - pagesResult, _ := json.Marshal(resp.Pages) - r.Pages = jsontypes.NewNormalizedValue(string(pagesResult)) - } - r.PortalID = types.StringPointerValue(resp.PortalID) - r.PortalSkV3 = types.StringPointerValue(resp.PortalSkV3) - r.PreventSearchEngineIndexing = types.BoolPointerValue(resp.PreventSearchEngineIndexing) - if resp.RegistrationIdentifiers == nil { - r.RegistrationIdentifiers = jsontypes.NewNormalizedNull() - } else { - registrationIdentifiersResult, _ := json.Marshal(resp.RegistrationIdentifiers) - r.RegistrationIdentifiers = jsontypes.NewNormalizedValue(string(registrationIdentifiersResult)) - } - if resp.SelfRegistrationSetting != nil { - r.SelfRegistrationSetting = types.StringValue(string(*resp.SelfRegistrationSetting)) - } else { - r.SelfRegistrationSetting = types.StringNull() - } - r.TriggeredJourneys = []tfTypes.PortalConfigV3TriggeredJourneys{} - - for _, triggeredJourneysItem := range resp.TriggeredJourneys { - var triggeredJourneys tfTypes.PortalConfigV3TriggeredJourneys - - triggeredJourneys.JourneyID = types.StringPointerValue(triggeredJourneysItem.JourneyID) - if triggeredJourneysItem.TriggerName != nil { - triggeredJourneys.TriggerName = types.StringValue(string(*triggeredJourneysItem.TriggerName)) - } else { - triggeredJourneys.TriggerName = types.StringNull() - } - - r.TriggeredJourneys = append(r.TriggeredJourneys, triggeredJourneys) - } - } - - return diags -} - -func (r *PortalConfigResourceModel) ToOperationsDeletePortalConfigRequest(ctx context.Context) (*operations.DeletePortalConfigRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var portalID string - portalID = r.PortalID.ValueString() - - out := operations.DeletePortalConfigRequest{ - PortalID: portalID, - } - - return &out, diags -} - -func (r *PortalConfigResourceModel) ToOperationsGetPortalConfigV3Request(ctx context.Context) (*operations.GetPortalConfigV3Request, diag.Diagnostics) { - var diags diag.Diagnostics - - var portalID string - portalID = r.PortalID.ValueString() - - out := operations.GetPortalConfigV3Request{ - PortalID: portalID, - } - - return &out, diags -} - -func (r *PortalConfigResourceModel) ToOperationsPutPortalConfigRequest(ctx context.Context) (*operations.PutPortalConfigRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - portalConfigV3, portalConfigV3Diags := r.ToSharedPortalConfigV3(ctx) - diags.Append(portalConfigV3Diags...) - - if diags.HasError() { - return nil, diags - } - - var portalID string - portalID = r.PortalID.ValueString() - - out := operations.PutPortalConfigRequest{ - PortalConfigV3: *portalConfigV3, - PortalID: portalID, - } - - return &out, diags -} - -func (r *PortalConfigResourceModel) ToSharedPortalConfigV3(ctx context.Context) (*shared.PortalConfigV3, diag.Diagnostics) { - var diags diag.Diagnostics - - accessToken := new(string) - if !r.AccessToken.IsUnknown() && !r.AccessToken.IsNull() { - *accessToken = r.AccessToken.ValueString() - } else { - accessToken = nil - } - var advancedMfa *shared.PortalConfigV3AdvancedMfa - if r.AdvancedMfa != nil { - enabled := new(bool) - if !r.AdvancedMfa.Enabled.IsUnknown() && !r.AdvancedMfa.Enabled.IsNull() { - *enabled = r.AdvancedMfa.Enabled.ValueBool() - } else { - enabled = nil - } - advancedMfa = &shared.PortalConfigV3AdvancedMfa{ - Enabled: enabled, - } - } - var allowedFileExtensions *shared.AllowedFileExtensions - if r.AllowedFileExtensions != nil { - archive := make([]string, 0, len(r.AllowedFileExtensions.Archive)) - for _, archiveItem := range r.AllowedFileExtensions.Archive { - archive = append(archive, archiveItem.ValueString()) - } - audioVideo := make([]string, 0, len(r.AllowedFileExtensions.AudioVideo)) - for _, audioVideoItem := range r.AllowedFileExtensions.AudioVideo { - audioVideo = append(audioVideo, audioVideoItem.ValueString()) - } - cad := make([]string, 0, len(r.AllowedFileExtensions.Cad)) - for _, cadItem := range r.AllowedFileExtensions.Cad { - cad = append(cad, cadItem.ValueString()) - } - calendar := make([]string, 0, len(r.AllowedFileExtensions.Calendar)) - for _, calendarItem := range r.AllowedFileExtensions.Calendar { - calendar = append(calendar, calendarItem.ValueString()) - } - document := make([]string, 0, len(r.AllowedFileExtensions.Document)) - for _, documentItem := range r.AllowedFileExtensions.Document { - document = append(document, documentItem.ValueString()) - } - email := make([]string, 0, len(r.AllowedFileExtensions.Email)) - for _, emailItem := range r.AllowedFileExtensions.Email { - email = append(email, emailItem.ValueString()) - } - image := make([]string, 0, len(r.AllowedFileExtensions.Image)) - for _, imageItem := range r.AllowedFileExtensions.Image { - image = append(image, imageItem.ValueString()) - } - other := make([]string, 0, len(r.AllowedFileExtensions.Other)) - for _, otherItem := range r.AllowedFileExtensions.Other { - other = append(other, otherItem.ValueString()) - } - presentation := make([]string, 0, len(r.AllowedFileExtensions.Presentation)) - for _, presentationItem := range r.AllowedFileExtensions.Presentation { - presentation = append(presentation, presentationItem.ValueString()) - } - spreadsheet := make([]string, 0, len(r.AllowedFileExtensions.Spreadsheet)) - for _, spreadsheetItem := range r.AllowedFileExtensions.Spreadsheet { - spreadsheet = append(spreadsheet, spreadsheetItem.ValueString()) - } - allowedFileExtensions = &shared.AllowedFileExtensions{ - Archive: archive, - AudioVideo: audioVideo, - Cad: cad, - Calendar: calendar, - Document: document, - Email: email, - Image: image, - Other: other, - Presentation: presentation, - Spreadsheet: spreadsheet, - } - } - var approvalStateAttributes interface{} - if !r.ApprovalStateAttributes.IsUnknown() && !r.ApprovalStateAttributes.IsNull() { - _ = json.Unmarshal([]byte(r.ApprovalStateAttributes.ValueString()), &approvalStateAttributes) - } - var authSettings *shared.PortalConfigV3AuthSettings - if r.AuthSettings != nil { - autoRedirectToSso := new(bool) - if !r.AuthSettings.AutoRedirectToSso.IsUnknown() && !r.AuthSettings.AutoRedirectToSso.IsNull() { - *autoRedirectToSso = r.AuthSettings.AutoRedirectToSso.ValueBool() - } else { - autoRedirectToSso = nil - } - entryPoint := new(shared.PortalConfigV3EntryPoint) - if !r.AuthSettings.EntryPoint.IsUnknown() && !r.AuthSettings.EntryPoint.IsNull() { - *entryPoint = shared.PortalConfigV3EntryPoint(r.AuthSettings.EntryPoint.ValueString()) - } else { - entryPoint = nil - } - var passwordlessLogin *shared.PortalConfigV3PasswordlessLogin - if r.AuthSettings.PasswordlessLogin != nil { - enabled1 := new(bool) - if !r.AuthSettings.PasswordlessLogin.Enabled.IsUnknown() && !r.AuthSettings.PasswordlessLogin.Enabled.IsNull() { - *enabled1 = r.AuthSettings.PasswordlessLogin.Enabled.ValueBool() - } else { - enabled1 = nil - } - passwordlessLogin = &shared.PortalConfigV3PasswordlessLogin{ - Enabled: enabled1, - } - } - preferredSsoProviders := make([]string, 0, len(r.AuthSettings.PreferredSsoProviders)) - for _, preferredSsoProvidersItem := range r.AuthSettings.PreferredSsoProviders { - preferredSsoProviders = append(preferredSsoProviders, preferredSsoProvidersItem.ValueString()) - } - authSettings = &shared.PortalConfigV3AuthSettings{ - AutoRedirectToSso: autoRedirectToSso, - EntryPoint: entryPoint, - PasswordlessLogin: passwordlessLogin, - PreferredSsoProviders: preferredSsoProviders, - } - } - var cognitoDetails *shared.PortalConfigV3CognitoDetails - if r.CognitoDetails != nil { - cognitoUserPoolArn := new(string) - if !r.CognitoDetails.CognitoUserPoolArn.IsUnknown() && !r.CognitoDetails.CognitoUserPoolArn.IsNull() { - *cognitoUserPoolArn = r.CognitoDetails.CognitoUserPoolArn.ValueString() - } else { - cognitoUserPoolArn = nil - } - cognitoUserPoolClientID := new(string) - if !r.CognitoDetails.CognitoUserPoolClientID.IsUnknown() && !r.CognitoDetails.CognitoUserPoolClientID.IsNull() { - *cognitoUserPoolClientID = r.CognitoDetails.CognitoUserPoolClientID.ValueString() - } else { - cognitoUserPoolClientID = nil - } - cognitoUserPoolID := new(string) - if !r.CognitoDetails.CognitoUserPoolID.IsUnknown() && !r.CognitoDetails.CognitoUserPoolID.IsNull() { - *cognitoUserPoolID = r.CognitoDetails.CognitoUserPoolID.ValueString() - } else { - cognitoUserPoolID = nil - } - var passwordPolicy *shared.PortalConfigV3PasswordPolicy - if r.CognitoDetails.PasswordPolicy != nil { - minimumLength := new(int64) - if !r.CognitoDetails.PasswordPolicy.MinimumLength.IsUnknown() && !r.CognitoDetails.PasswordPolicy.MinimumLength.IsNull() { - *minimumLength = r.CognitoDetails.PasswordPolicy.MinimumLength.ValueInt64() - } else { - minimumLength = nil - } - requireLowercase := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireLowercase.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireLowercase.IsNull() { - *requireLowercase = r.CognitoDetails.PasswordPolicy.RequireLowercase.ValueBool() - } else { - requireLowercase = nil - } - requireNumbers := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireNumbers.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireNumbers.IsNull() { - *requireNumbers = r.CognitoDetails.PasswordPolicy.RequireNumbers.ValueBool() - } else { - requireNumbers = nil - } - requireSymbols := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireSymbols.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireSymbols.IsNull() { - *requireSymbols = r.CognitoDetails.PasswordPolicy.RequireSymbols.ValueBool() - } else { - requireSymbols = nil - } - requireUppercase := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireUppercase.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireUppercase.IsNull() { - *requireUppercase = r.CognitoDetails.PasswordPolicy.RequireUppercase.ValueBool() - } else { - requireUppercase = nil - } - passwordPolicy = &shared.PortalConfigV3PasswordPolicy{ - MinimumLength: minimumLength, - RequireLowercase: requireLowercase, - RequireNumbers: requireNumbers, - RequireSymbols: requireSymbols, - RequireUppercase: requireUppercase, - } - } - cognitoDetails = &shared.PortalConfigV3CognitoDetails{ - CognitoUserPoolArn: cognitoUserPoolArn, - CognitoUserPoolClientID: cognitoUserPoolClientID, - CognitoUserPoolID: cognitoUserPoolID, - PasswordPolicy: passwordPolicy, - } - } - config := new(string) - if !r.Config.IsUnknown() && !r.Config.IsNull() { - *config = r.Config.ValueString() - } else { - config = nil - } - contactIdentifiers := make([]string, 0, len(r.ContactIdentifiers)) - for _, contactIdentifiersItem := range r.ContactIdentifiers { - contactIdentifiers = append(contactIdentifiers, contactIdentifiersItem.ValueString()) - } - var contractIdentifiers interface{} - if !r.ContractIdentifiers.IsUnknown() && !r.ContractIdentifiers.IsNull() { - _ = json.Unmarshal([]byte(r.ContractIdentifiers.ValueString()), &contractIdentifiers) - } - var contractSelectorConfig *shared.PortalConfigV3ContractSelectorConfig - if r.ContractSelectorConfig != nil { - showInactive := new(bool) - if !r.ContractSelectorConfig.ShowInactive.IsUnknown() && !r.ContractSelectorConfig.ShowInactive.IsNull() { - *showInactive = r.ContractSelectorConfig.ShowInactive.ValueBool() - } else { - showInactive = nil - } - titlePath := new(string) - if !r.ContractSelectorConfig.TitlePath.IsUnknown() && !r.ContractSelectorConfig.TitlePath.IsNull() { - *titlePath = r.ContractSelectorConfig.TitlePath.ValueString() - } else { - titlePath = nil - } - contractSelectorConfig = &shared.PortalConfigV3ContractSelectorConfig{ - ShowInactive: showInactive, - TitlePath: titlePath, - } - } - var defaultUserToNotify *shared.DefaultUserToNotify - if r.DefaultUserToNotify != nil { - onPendingUser := make([]shared.AdminUser, 0, len(r.DefaultUserToNotify.OnPendingUser)) - for _, onPendingUserItem := range r.DefaultUserToNotify.OnPendingUser { - var additionalProperties interface{} - if !onPendingUserItem.AdditionalProperties.IsUnknown() && !onPendingUserItem.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(onPendingUserItem.AdditionalProperties.ValueString()), &additionalProperties) - } - displayName := new(string) - if !onPendingUserItem.DisplayName.IsUnknown() && !onPendingUserItem.DisplayName.IsNull() { - *displayName = onPendingUserItem.DisplayName.ValueString() - } else { - displayName = nil - } - email1 := new(string) - if !onPendingUserItem.Email.IsUnknown() && !onPendingUserItem.Email.IsNull() { - *email1 = onPendingUserItem.Email.ValueString() - } else { - email1 = nil - } - var imageURI *shared.ImageURI - if onPendingUserItem.ImageURI != nil { - key := new(string) - if !onPendingUserItem.ImageURI.Key.IsUnknown() && !onPendingUserItem.ImageURI.Key.IsNull() { - *key = onPendingUserItem.ImageURI.Key.ValueString() - } else { - key = nil - } - original := new(string) - if !onPendingUserItem.ImageURI.Original.IsUnknown() && !onPendingUserItem.ImageURI.Original.IsNull() { - *original = onPendingUserItem.ImageURI.Original.ValueString() - } else { - original = nil - } - thumbnail32 := new(string) - if !onPendingUserItem.ImageURI.Thumbnail32.IsUnknown() && !onPendingUserItem.ImageURI.Thumbnail32.IsNull() { - *thumbnail32 = onPendingUserItem.ImageURI.Thumbnail32.ValueString() - } else { - thumbnail32 = nil - } - thumbnail64 := new(string) - if !onPendingUserItem.ImageURI.Thumbnail64.IsUnknown() && !onPendingUserItem.ImageURI.Thumbnail64.IsNull() { - *thumbnail64 = onPendingUserItem.ImageURI.Thumbnail64.ValueString() - } else { - thumbnail64 = nil - } - imageURI = &shared.ImageURI{ - Key: key, - Original: original, - Thumbnail32: thumbnail32, - Thumbnail64: thumbnail64, - } - } - orgID := new(string) - if !onPendingUserItem.OrgID.IsUnknown() && !onPendingUserItem.OrgID.IsNull() { - *orgID = onPendingUserItem.OrgID.ValueString() - } else { - orgID = nil - } - phone := new(string) - if !onPendingUserItem.Phone.IsUnknown() && !onPendingUserItem.Phone.IsNull() { - *phone = onPendingUserItem.Phone.ValueString() - } else { - phone = nil - } - typeVar := new(string) - if !onPendingUserItem.Type.IsUnknown() && !onPendingUserItem.Type.IsNull() { - *typeVar = onPendingUserItem.Type.ValueString() - } else { - typeVar = nil - } - userID := new(string) - if !onPendingUserItem.UserID.IsUnknown() && !onPendingUserItem.UserID.IsNull() { - *userID = onPendingUserItem.UserID.ValueString() - } else { - userID = nil - } - onPendingUser = append(onPendingUser, shared.AdminUser{ - AdditionalProperties: additionalProperties, - DisplayName: displayName, - Email: email1, - ImageURI: imageURI, - OrgID: orgID, - Phone: phone, - Type: typeVar, - UserID: userID, - }) - } - defaultUserToNotify = &shared.DefaultUserToNotify{ - OnPendingUser: onPendingUser, - } - } - designID := new(string) - if !r.DesignID.IsUnknown() && !r.DesignID.IsNull() { - *designID = r.DesignID.ValueString() - } else { - designID = nil - } - domain := new(string) - if !r.Domain.IsUnknown() && !r.Domain.IsNull() { - *domain = r.Domain.ValueString() - } else { - domain = nil - } - var emailTemplates *shared.EmailTemplates - if r.EmailTemplates != nil { - advancedAuth := new(string) - if !r.EmailTemplates.AdvancedAuth.IsUnknown() && !r.EmailTemplates.AdvancedAuth.IsNull() { - *advancedAuth = r.EmailTemplates.AdvancedAuth.ValueString() - } else { - advancedAuth = nil - } - advancedMFA := new(string) - if !r.EmailTemplates.AdvancedMFA.IsUnknown() && !r.EmailTemplates.AdvancedMFA.IsNull() { - *advancedMFA = r.EmailTemplates.AdvancedMFA.ValueString() - } else { - advancedMFA = nil - } - confirmAccount := new(string) - if !r.EmailTemplates.ConfirmAccount.IsUnknown() && !r.EmailTemplates.ConfirmAccount.IsNull() { - *confirmAccount = r.EmailTemplates.ConfirmAccount.ValueString() - } else { - confirmAccount = nil - } - confirmEmailUpdate := new(string) - if !r.EmailTemplates.ConfirmEmailUpdate.IsUnknown() && !r.EmailTemplates.ConfirmEmailUpdate.IsNull() { - *confirmEmailUpdate = r.EmailTemplates.ConfirmEmailUpdate.ValueString() - } else { - confirmEmailUpdate = nil - } - forgotPassword := new(string) - if !r.EmailTemplates.ForgotPassword.IsUnknown() && !r.EmailTemplates.ForgotPassword.IsNull() { - *forgotPassword = r.EmailTemplates.ForgotPassword.ValueString() - } else { - forgotPassword = nil - } - invitation := new(string) - if !r.EmailTemplates.Invitation.IsUnknown() && !r.EmailTemplates.Invitation.IsNull() { - *invitation = r.EmailTemplates.Invitation.ValueString() - } else { - invitation = nil - } - journeyLoginOTP := new(string) - if !r.EmailTemplates.JourneyLoginOTP.IsUnknown() && !r.EmailTemplates.JourneyLoginOTP.IsNull() { - *journeyLoginOTP = r.EmailTemplates.JourneyLoginOTP.ValueString() - } else { - journeyLoginOTP = nil - } - journeySignInOneTimePassword := new(string) - if !r.EmailTemplates.JourneySignInOneTimePassword.IsUnknown() && !r.EmailTemplates.JourneySignInOneTimePassword.IsNull() { - *journeySignInOneTimePassword = r.EmailTemplates.JourneySignInOneTimePassword.ValueString() - } else { - journeySignInOneTimePassword = nil - } - journeySignUp := new(string) - if !r.EmailTemplates.JourneySignUp.IsUnknown() && !r.EmailTemplates.JourneySignUp.IsNull() { - *journeySignUp = r.EmailTemplates.JourneySignUp.ValueString() - } else { - journeySignUp = nil - } - onDocUpload := new(string) - if !r.EmailTemplates.OnDocUpload.IsUnknown() && !r.EmailTemplates.OnDocUpload.IsNull() { - *onDocUpload = r.EmailTemplates.OnDocUpload.ValueString() - } else { - onDocUpload = nil - } - onMapAPendingUser := new(string) - if !r.EmailTemplates.OnMapAPendingUser.IsUnknown() && !r.EmailTemplates.OnMapAPendingUser.IsNull() { - *onMapAPendingUser = r.EmailTemplates.OnMapAPendingUser.ValueString() - } else { - onMapAPendingUser = nil - } - onNewQuote := new(string) - if !r.EmailTemplates.OnNewQuote.IsUnknown() && !r.EmailTemplates.OnNewQuote.IsNull() { - *onNewQuote = r.EmailTemplates.OnNewQuote.ValueString() - } else { - onNewQuote = nil - } - onWorkflowStepAssigned := new(string) - if !r.EmailTemplates.OnWorkflowStepAssigned.IsUnknown() && !r.EmailTemplates.OnWorkflowStepAssigned.IsNull() { - *onWorkflowStepAssigned = r.EmailTemplates.OnWorkflowStepAssigned.ValueString() - } else { - onWorkflowStepAssigned = nil - } - verifyCodeToSetPassword := new(string) - if !r.EmailTemplates.VerifyCodeToSetPassword.IsUnknown() && !r.EmailTemplates.VerifyCodeToSetPassword.IsNull() { - *verifyCodeToSetPassword = r.EmailTemplates.VerifyCodeToSetPassword.ValueString() - } else { - verifyCodeToSetPassword = nil - } - emailTemplates = &shared.EmailTemplates{ - AdvancedAuth: advancedAuth, - AdvancedMFA: advancedMFA, - ConfirmAccount: confirmAccount, - ConfirmEmailUpdate: confirmEmailUpdate, - ForgotPassword: forgotPassword, - Invitation: invitation, - JourneyLoginOTP: journeyLoginOTP, - JourneySignInOneTimePassword: journeySignInOneTimePassword, - JourneySignUp: journeySignUp, - OnDocUpload: onDocUpload, - OnMapAPendingUser: onMapAPendingUser, - OnNewQuote: onNewQuote, - OnWorkflowStepAssigned: onWorkflowStepAssigned, - VerifyCodeToSetPassword: verifyCodeToSetPassword, - } - } - enabled2 := new(bool) - if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { - *enabled2 = r.Enabled.ValueBool() - } else { - enabled2 = nil - } - entityActions := make([]shared.EntityActions, 0, len(r.EntityActions)) - for _, entityActionsItem := range r.EntityActions { - var actionLabel *shared.PortalConfigV3ActionLabel - if entityActionsItem.ActionLabel != nil { - de := new(string) - if !entityActionsItem.ActionLabel.De.IsUnknown() && !entityActionsItem.ActionLabel.De.IsNull() { - *de = entityActionsItem.ActionLabel.De.ValueString() - } else { - de = nil - } - en := new(string) - if !entityActionsItem.ActionLabel.En.IsUnknown() && !entityActionsItem.ActionLabel.En.IsNull() { - *en = entityActionsItem.ActionLabel.En.ValueString() - } else { - en = nil - } - actionLabel = &shared.PortalConfigV3ActionLabel{ - De: de, - En: en, - } - } - journeyID := new(string) - if !entityActionsItem.JourneyID.IsUnknown() && !entityActionsItem.JourneyID.IsNull() { - *journeyID = entityActionsItem.JourneyID.ValueString() - } else { - journeyID = nil - } - slug := new(shared.EntitySlug) - if !entityActionsItem.Slug.IsUnknown() && !entityActionsItem.Slug.IsNull() { - *slug = shared.EntitySlug(entityActionsItem.Slug.ValueString()) - } else { - slug = nil - } - entityActions = append(entityActions, shared.EntityActions{ - ActionLabel: actionLabel, - JourneyID: journeyID, - Slug: slug, - }) - } - var entityEditRules interface{} - if !r.EntityEditRules.IsUnknown() && !r.EntityEditRules.IsNull() { - _ = json.Unmarshal([]byte(r.EntityEditRules.ValueString()), &entityEditRules) - } - var entityIdentifiers *shared.PortalConfigV3EntityIdentifiers - if r.EntityIdentifiers != nil { - var typeVar1 *shared.PortalConfigV3Type - if r.EntityIdentifiers.Type != nil { - attributes := make([]string, 0, len(r.EntityIdentifiers.Type.Attributes)) - for _, attributesItem := range r.EntityIdentifiers.Type.Attributes { - attributes = append(attributes, attributesItem.ValueString()) - } - isEnabled := new(bool) - if !r.EntityIdentifiers.Type.IsEnabled.IsUnknown() && !r.EntityIdentifiers.Type.IsEnabled.IsNull() { - *isEnabled = r.EntityIdentifiers.Type.IsEnabled.ValueBool() - } else { - isEnabled = nil - } - typeVar1 = &shared.PortalConfigV3Type{ - Attributes: attributes, - IsEnabled: isEnabled, - } - } - entityIdentifiers = &shared.PortalConfigV3EntityIdentifiers{ - Type: typeVar1, - } - } - extensionHooks := make(map[string]*shared.ExtensionHookConfig) - for extensionHooksKey, extensionHooksValue := range r.ExtensionHooks { - var extensionHooksInst *shared.ExtensionHookConfig - appID := new(string) - if !extensionHooksValue.AppID.IsUnknown() && !extensionHooksValue.AppID.IsNull() { - *appID = extensionHooksValue.AppID.ValueString() - } else { - appID = nil - } - hookID := new(string) - if !extensionHooksValue.HookID.IsUnknown() && !extensionHooksValue.HookID.IsNull() { - *hookID = extensionHooksValue.HookID.ValueString() - } else { - hookID = nil - } - extensionHooksInst = &shared.ExtensionHookConfig{ - AppID: appID, - HookID: hookID, - } - extensionHooks[extensionHooksKey] = extensionHooksInst - } - extensions := make([]shared.ExtensionConfig, 0, len(r.Extensions)) - for _, extensionsItem := range r.Extensions { - var id string - id = extensionsItem.ID.ValueString() - - optionsVar := make(map[string]string) - for optionsKey, optionsValue := range extensionsItem.Options { - var optionsInst string - optionsInst = optionsValue.ValueString() - - optionsVar[optionsKey] = optionsInst - } - status := new(shared.ExtensionConfigStatus) - if !extensionsItem.Status.IsUnknown() && !extensionsItem.Status.IsNull() { - *status = shared.ExtensionConfigStatus(extensionsItem.Status.ValueString()) - } else { - status = nil - } - extensions = append(extensions, shared.ExtensionConfig{ - ID: id, - Options: optionsVar, - Status: status, - }) - } - var featureFlags interface{} - if !r.FeatureFlags.IsUnknown() && !r.FeatureFlags.IsNull() { - _ = json.Unmarshal([]byte(r.FeatureFlags.ValueString()), &featureFlags) - } - var featureSettings *shared.PortalConfigV3FeatureSettings - if r.FeatureSettings != nil { - billing := new(bool) - if !r.FeatureSettings.Billing.IsUnknown() && !r.FeatureSettings.Billing.IsNull() { - *billing = r.FeatureSettings.Billing.ValueBool() - } else { - billing = nil - } - changeDueDate := new(bool) - if !r.FeatureSettings.ChangeDueDate.IsUnknown() && !r.FeatureSettings.ChangeDueDate.IsNull() { - *changeDueDate = r.FeatureSettings.ChangeDueDate.ValueBool() - } else { - changeDueDate = nil - } - newDesign := new(bool) - if !r.FeatureSettings.NewDesign.IsUnknown() && !r.FeatureSettings.NewDesign.IsNull() { - *newDesign = r.FeatureSettings.NewDesign.ValueBool() - } else { - newDesign = nil - } - startPage := new(bool) - if !r.FeatureSettings.StartPage.IsUnknown() && !r.FeatureSettings.StartPage.IsNull() { - *startPage = r.FeatureSettings.StartPage.ValueBool() - } else { - startPage = nil - } - featureSettings = &shared.PortalConfigV3FeatureSettings{ - Billing: billing, - ChangeDueDate: changeDueDate, - NewDesign: newDesign, - StartPage: startPage, - } - } - var grants interface{} - if !r.Grants.IsUnknown() && !r.Grants.IsNull() { - _ = json.Unmarshal([]byte(r.Grants.ValueString()), &grants) - } - var identityProviders interface{} - if !r.IdentityProviders.IsUnknown() && !r.IdentityProviders.IsNull() { - _ = json.Unmarshal([]byte(r.IdentityProviders.ValueString()), &identityProviders) - } - var images *shared.PortalConfigV3Images - if r.Images != nil { - orderLeftTeaser := new(string) - if !r.Images.OrderLeftTeaser.IsUnknown() && !r.Images.OrderLeftTeaser.IsNull() { - *orderLeftTeaser = r.Images.OrderLeftTeaser.ValueString() - } else { - orderLeftTeaser = nil - } - orderRightTeaser := new(string) - if !r.Images.OrderRightTeaser.IsUnknown() && !r.Images.OrderRightTeaser.IsNull() { - *orderRightTeaser = r.Images.OrderRightTeaser.ValueString() - } else { - orderRightTeaser = nil - } - welcomeBanner := new(string) - if !r.Images.WelcomeBanner.IsUnknown() && !r.Images.WelcomeBanner.IsNull() { - *welcomeBanner = r.Images.WelcomeBanner.ValueString() - } else { - welcomeBanner = nil - } - images = &shared.PortalConfigV3Images{ - OrderLeftTeaser: orderLeftTeaser, - OrderRightTeaser: orderRightTeaser, - WelcomeBanner: welcomeBanner, - } - } - inactiveContractCutoffYears := new(float64) - if !r.InactiveContractCutoffYears.IsUnknown() && !r.InactiveContractCutoffYears.IsNull() { - *inactiveContractCutoffYears = r.InactiveContractCutoffYears.ValueFloat64() - } else { - inactiveContractCutoffYears = nil - } - isDummy := new(bool) - if !r.IsDummy.IsUnknown() && !r.IsDummy.IsNull() { - *isDummy = r.IsDummy.ValueBool() - } else { - isDummy = nil - } - isEpilotDomain := new(bool) - if !r.IsEpilotDomain.IsUnknown() && !r.IsEpilotDomain.IsNull() { - *isEpilotDomain = r.IsEpilotDomain.ValueBool() - } else { - isEpilotDomain = nil - } - isV3Item := new(bool) - if !r.IsV3Item.IsUnknown() && !r.IsV3Item.IsNull() { - *isV3Item = r.IsV3Item.ValueBool() - } else { - isV3Item = nil - } - meterReadingGracePeriod := new(float64) - if !r.MeterReadingGracePeriod.IsUnknown() && !r.MeterReadingGracePeriod.IsNull() { - *meterReadingGracePeriod = r.MeterReadingGracePeriod.ValueFloat64() - } else { - meterReadingGracePeriod = nil - } - name := new(string) - if !r.Name.IsUnknown() && !r.Name.IsNull() { - *name = r.Name.ValueString() - } else { - name = nil - } - var orgSettings *shared.PortalConfigV3OrgSettings - if r.OrgSettings != nil { - var canary *shared.PortalConfigV3Canary - if r.OrgSettings.Canary != nil { - enabled3 := new(bool) - if !r.OrgSettings.Canary.Enabled.IsUnknown() && !r.OrgSettings.Canary.Enabled.IsNull() { - *enabled3 = r.OrgSettings.Canary.Enabled.ValueBool() - } else { - enabled3 = nil - } - canary = &shared.PortalConfigV3Canary{ - Enabled: enabled3, - } - } - var notracking *shared.PortalConfigV3Notracking - if r.OrgSettings.Notracking != nil { - enabled4 := new(bool) - if !r.OrgSettings.Notracking.Enabled.IsUnknown() && !r.OrgSettings.Notracking.Enabled.IsNull() { - *enabled4 = r.OrgSettings.Notracking.Enabled.ValueBool() - } else { - enabled4 = nil - } - notracking = &shared.PortalConfigV3Notracking{ - Enabled: enabled4, - } - } - orgSettings = &shared.PortalConfigV3OrgSettings{ - Canary: canary, - Notracking: notracking, - } - } - organizationID := new(string) - if !r.OrganizationID.IsUnknown() && !r.OrganizationID.IsNull() { - *organizationID = r.OrganizationID.ValueString() - } else { - organizationID = nil - } - origin := new(string) - if !r.Origin.IsUnknown() && !r.Origin.IsNull() { - *origin = r.Origin.ValueString() - } else { - origin = nil - } - var pages interface{} - if !r.Pages.IsUnknown() && !r.Pages.IsNull() { - _ = json.Unmarshal([]byte(r.Pages.ValueString()), &pages) - } - portalID := new(string) - if !r.PortalID.IsUnknown() && !r.PortalID.IsNull() { - *portalID = r.PortalID.ValueString() - } else { - portalID = nil - } - portalSkV3 := new(string) - if !r.PortalSkV3.IsUnknown() && !r.PortalSkV3.IsNull() { - *portalSkV3 = r.PortalSkV3.ValueString() - } else { - portalSkV3 = nil - } - preventSearchEngineIndexing := new(bool) - if !r.PreventSearchEngineIndexing.IsUnknown() && !r.PreventSearchEngineIndexing.IsNull() { - *preventSearchEngineIndexing = r.PreventSearchEngineIndexing.ValueBool() - } else { - preventSearchEngineIndexing = nil - } - var registrationIdentifiers interface{} - if !r.RegistrationIdentifiers.IsUnknown() && !r.RegistrationIdentifiers.IsNull() { - _ = json.Unmarshal([]byte(r.RegistrationIdentifiers.ValueString()), ®istrationIdentifiers) - } - selfRegistrationSetting := new(shared.PortalConfigV3SelfRegistrationSetting) - if !r.SelfRegistrationSetting.IsUnknown() && !r.SelfRegistrationSetting.IsNull() { - *selfRegistrationSetting = shared.PortalConfigV3SelfRegistrationSetting(r.SelfRegistrationSetting.ValueString()) - } else { - selfRegistrationSetting = nil - } - triggeredJourneys := make([]shared.PortalConfigV3TriggeredJourneys, 0, len(r.TriggeredJourneys)) - for _, triggeredJourneysItem := range r.TriggeredJourneys { - journeyId1 := new(string) - if !triggeredJourneysItem.JourneyID.IsUnknown() && !triggeredJourneysItem.JourneyID.IsNull() { - *journeyId1 = triggeredJourneysItem.JourneyID.ValueString() - } else { - journeyId1 = nil - } - triggerName := new(shared.PortalConfigV3TriggerName) - if !triggeredJourneysItem.TriggerName.IsUnknown() && !triggeredJourneysItem.TriggerName.IsNull() { - *triggerName = shared.PortalConfigV3TriggerName(triggeredJourneysItem.TriggerName.ValueString()) - } else { - triggerName = nil - } - triggeredJourneys = append(triggeredJourneys, shared.PortalConfigV3TriggeredJourneys{ - JourneyID: journeyId1, - TriggerName: triggerName, - }) - } - out := shared.PortalConfigV3{ - AccessToken: accessToken, - AdvancedMfa: advancedMfa, - AllowedFileExtensions: allowedFileExtensions, - ApprovalStateAttributes: approvalStateAttributes, - AuthSettings: authSettings, - CognitoDetails: cognitoDetails, - Config: config, - ContactIdentifiers: contactIdentifiers, - ContractIdentifiers: contractIdentifiers, - ContractSelectorConfig: contractSelectorConfig, - DefaultUserToNotify: defaultUserToNotify, - DesignID: designID, - Domain: domain, - EmailTemplates: emailTemplates, - Enabled: enabled2, - EntityActions: entityActions, - EntityEditRules: entityEditRules, - EntityIdentifiers: entityIdentifiers, - ExtensionHooks: extensionHooks, - Extensions: extensions, - FeatureFlags: featureFlags, - FeatureSettings: featureSettings, - Grants: grants, - IdentityProviders: identityProviders, - Images: images, - InactiveContractCutoffYears: inactiveContractCutoffYears, - IsDummy: isDummy, - IsEpilotDomain: isEpilotDomain, - IsV3Item: isV3Item, - MeterReadingGracePeriod: meterReadingGracePeriod, - Name: name, - OrgSettings: orgSettings, - OrganizationID: organizationID, - Origin: origin, - Pages: pages, - PortalID: portalID, - PortalSkV3: portalSkV3, - PreventSearchEngineIndexing: preventSearchEngineIndexing, - RegistrationIdentifiers: registrationIdentifiers, - SelfRegistrationSetting: selfRegistrationSetting, - TriggeredJourneys: triggeredJourneys, - } - - return &out, diags -} - -func (r *PortalConfigResourceModel) ToSharedUpsertPortalConfigV3(ctx context.Context) (*shared.UpsertPortalConfigV3, diag.Diagnostics) { - var diags diag.Diagnostics - - accessToken := new(string) - if !r.AccessToken.IsUnknown() && !r.AccessToken.IsNull() { - *accessToken = r.AccessToken.ValueString() - } else { - accessToken = nil - } - var advancedMfa *shared.UpsertPortalConfigV3AdvancedMfa - if r.AdvancedMfa != nil { - enabled := new(bool) - if !r.AdvancedMfa.Enabled.IsUnknown() && !r.AdvancedMfa.Enabled.IsNull() { - *enabled = r.AdvancedMfa.Enabled.ValueBool() - } else { - enabled = nil - } - advancedMfa = &shared.UpsertPortalConfigV3AdvancedMfa{ - Enabled: enabled, - } - } - var allowedFileExtensions *shared.AllowedFileExtensions - if r.AllowedFileExtensions != nil { - archive := make([]string, 0, len(r.AllowedFileExtensions.Archive)) - for _, archiveItem := range r.AllowedFileExtensions.Archive { - archive = append(archive, archiveItem.ValueString()) - } - audioVideo := make([]string, 0, len(r.AllowedFileExtensions.AudioVideo)) - for _, audioVideoItem := range r.AllowedFileExtensions.AudioVideo { - audioVideo = append(audioVideo, audioVideoItem.ValueString()) - } - cad := make([]string, 0, len(r.AllowedFileExtensions.Cad)) - for _, cadItem := range r.AllowedFileExtensions.Cad { - cad = append(cad, cadItem.ValueString()) - } - calendar := make([]string, 0, len(r.AllowedFileExtensions.Calendar)) - for _, calendarItem := range r.AllowedFileExtensions.Calendar { - calendar = append(calendar, calendarItem.ValueString()) - } - document := make([]string, 0, len(r.AllowedFileExtensions.Document)) - for _, documentItem := range r.AllowedFileExtensions.Document { - document = append(document, documentItem.ValueString()) - } - email := make([]string, 0, len(r.AllowedFileExtensions.Email)) - for _, emailItem := range r.AllowedFileExtensions.Email { - email = append(email, emailItem.ValueString()) - } - image := make([]string, 0, len(r.AllowedFileExtensions.Image)) - for _, imageItem := range r.AllowedFileExtensions.Image { - image = append(image, imageItem.ValueString()) - } - other := make([]string, 0, len(r.AllowedFileExtensions.Other)) - for _, otherItem := range r.AllowedFileExtensions.Other { - other = append(other, otherItem.ValueString()) - } - presentation := make([]string, 0, len(r.AllowedFileExtensions.Presentation)) - for _, presentationItem := range r.AllowedFileExtensions.Presentation { - presentation = append(presentation, presentationItem.ValueString()) - } - spreadsheet := make([]string, 0, len(r.AllowedFileExtensions.Spreadsheet)) - for _, spreadsheetItem := range r.AllowedFileExtensions.Spreadsheet { - spreadsheet = append(spreadsheet, spreadsheetItem.ValueString()) - } - allowedFileExtensions = &shared.AllowedFileExtensions{ - Archive: archive, - AudioVideo: audioVideo, - Cad: cad, - Calendar: calendar, - Document: document, - Email: email, - Image: image, - Other: other, - Presentation: presentation, - Spreadsheet: spreadsheet, - } - } - var approvalStateAttributes interface{} - if !r.ApprovalStateAttributes.IsUnknown() && !r.ApprovalStateAttributes.IsNull() { - _ = json.Unmarshal([]byte(r.ApprovalStateAttributes.ValueString()), &approvalStateAttributes) - } - var authSettings *shared.UpsertPortalConfigV3AuthSettings - if r.AuthSettings != nil { - autoRedirectToSso := new(bool) - if !r.AuthSettings.AutoRedirectToSso.IsUnknown() && !r.AuthSettings.AutoRedirectToSso.IsNull() { - *autoRedirectToSso = r.AuthSettings.AutoRedirectToSso.ValueBool() - } else { - autoRedirectToSso = nil - } - entryPoint := new(shared.UpsertPortalConfigV3EntryPoint) - if !r.AuthSettings.EntryPoint.IsUnknown() && !r.AuthSettings.EntryPoint.IsNull() { - *entryPoint = shared.UpsertPortalConfigV3EntryPoint(r.AuthSettings.EntryPoint.ValueString()) - } else { - entryPoint = nil - } - var passwordlessLogin *shared.UpsertPortalConfigV3PasswordlessLogin - if r.AuthSettings.PasswordlessLogin != nil { - enabled1 := new(bool) - if !r.AuthSettings.PasswordlessLogin.Enabled.IsUnknown() && !r.AuthSettings.PasswordlessLogin.Enabled.IsNull() { - *enabled1 = r.AuthSettings.PasswordlessLogin.Enabled.ValueBool() - } else { - enabled1 = nil - } - passwordlessLogin = &shared.UpsertPortalConfigV3PasswordlessLogin{ - Enabled: enabled1, - } - } - preferredSsoProviders := make([]string, 0, len(r.AuthSettings.PreferredSsoProviders)) - for _, preferredSsoProvidersItem := range r.AuthSettings.PreferredSsoProviders { - preferredSsoProviders = append(preferredSsoProviders, preferredSsoProvidersItem.ValueString()) - } - authSettings = &shared.UpsertPortalConfigV3AuthSettings{ - AutoRedirectToSso: autoRedirectToSso, - EntryPoint: entryPoint, - PasswordlessLogin: passwordlessLogin, - PreferredSsoProviders: preferredSsoProviders, - } - } - var cognitoDetails *shared.UpsertPortalConfigV3CognitoDetails - if r.CognitoDetails != nil { - cognitoUserPoolArn := new(string) - if !r.CognitoDetails.CognitoUserPoolArn.IsUnknown() && !r.CognitoDetails.CognitoUserPoolArn.IsNull() { - *cognitoUserPoolArn = r.CognitoDetails.CognitoUserPoolArn.ValueString() - } else { - cognitoUserPoolArn = nil - } - cognitoUserPoolClientID := new(string) - if !r.CognitoDetails.CognitoUserPoolClientID.IsUnknown() && !r.CognitoDetails.CognitoUserPoolClientID.IsNull() { - *cognitoUserPoolClientID = r.CognitoDetails.CognitoUserPoolClientID.ValueString() - } else { - cognitoUserPoolClientID = nil - } - cognitoUserPoolID := new(string) - if !r.CognitoDetails.CognitoUserPoolID.IsUnknown() && !r.CognitoDetails.CognitoUserPoolID.IsNull() { - *cognitoUserPoolID = r.CognitoDetails.CognitoUserPoolID.ValueString() - } else { - cognitoUserPoolID = nil - } - var passwordPolicy *shared.UpsertPortalConfigV3PasswordPolicy - if r.CognitoDetails.PasswordPolicy != nil { - minimumLength := new(int64) - if !r.CognitoDetails.PasswordPolicy.MinimumLength.IsUnknown() && !r.CognitoDetails.PasswordPolicy.MinimumLength.IsNull() { - *minimumLength = r.CognitoDetails.PasswordPolicy.MinimumLength.ValueInt64() - } else { - minimumLength = nil - } - requireLowercase := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireLowercase.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireLowercase.IsNull() { - *requireLowercase = r.CognitoDetails.PasswordPolicy.RequireLowercase.ValueBool() - } else { - requireLowercase = nil - } - requireNumbers := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireNumbers.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireNumbers.IsNull() { - *requireNumbers = r.CognitoDetails.PasswordPolicy.RequireNumbers.ValueBool() - } else { - requireNumbers = nil - } - requireSymbols := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireSymbols.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireSymbols.IsNull() { - *requireSymbols = r.CognitoDetails.PasswordPolicy.RequireSymbols.ValueBool() - } else { - requireSymbols = nil - } - requireUppercase := new(bool) - if !r.CognitoDetails.PasswordPolicy.RequireUppercase.IsUnknown() && !r.CognitoDetails.PasswordPolicy.RequireUppercase.IsNull() { - *requireUppercase = r.CognitoDetails.PasswordPolicy.RequireUppercase.ValueBool() - } else { - requireUppercase = nil - } - passwordPolicy = &shared.UpsertPortalConfigV3PasswordPolicy{ - MinimumLength: minimumLength, - RequireLowercase: requireLowercase, - RequireNumbers: requireNumbers, - RequireSymbols: requireSymbols, - RequireUppercase: requireUppercase, - } - } - cognitoDetails = &shared.UpsertPortalConfigV3CognitoDetails{ - CognitoUserPoolArn: cognitoUserPoolArn, - CognitoUserPoolClientID: cognitoUserPoolClientID, - CognitoUserPoolID: cognitoUserPoolID, - PasswordPolicy: passwordPolicy, - } - } - config := new(string) - if !r.Config.IsUnknown() && !r.Config.IsNull() { - *config = r.Config.ValueString() - } else { - config = nil - } - contactIdentifiers := make([]string, 0, len(r.ContactIdentifiers)) - for _, contactIdentifiersItem := range r.ContactIdentifiers { - contactIdentifiers = append(contactIdentifiers, contactIdentifiersItem.ValueString()) - } - var contractIdentifiers interface{} - if !r.ContractIdentifiers.IsUnknown() && !r.ContractIdentifiers.IsNull() { - _ = json.Unmarshal([]byte(r.ContractIdentifiers.ValueString()), &contractIdentifiers) - } - var contractSelectorConfig *shared.UpsertPortalConfigV3ContractSelectorConfig - if r.ContractSelectorConfig != nil { - showInactive := new(bool) - if !r.ContractSelectorConfig.ShowInactive.IsUnknown() && !r.ContractSelectorConfig.ShowInactive.IsNull() { - *showInactive = r.ContractSelectorConfig.ShowInactive.ValueBool() - } else { - showInactive = nil - } - titlePath := new(string) - if !r.ContractSelectorConfig.TitlePath.IsUnknown() && !r.ContractSelectorConfig.TitlePath.IsNull() { - *titlePath = r.ContractSelectorConfig.TitlePath.ValueString() - } else { - titlePath = nil - } - contractSelectorConfig = &shared.UpsertPortalConfigV3ContractSelectorConfig{ - ShowInactive: showInactive, - TitlePath: titlePath, - } - } - var defaultUserToNotify *shared.UpsertPortalConfigV3DefaultUserToNotify - if r.DefaultUserToNotify != nil { - onPendingUser := make([]shared.AdminUser, 0, len(r.DefaultUserToNotify.OnPendingUser)) - for _, onPendingUserItem := range r.DefaultUserToNotify.OnPendingUser { - var additionalProperties interface{} - if !onPendingUserItem.AdditionalProperties.IsUnknown() && !onPendingUserItem.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(onPendingUserItem.AdditionalProperties.ValueString()), &additionalProperties) - } - displayName := new(string) - if !onPendingUserItem.DisplayName.IsUnknown() && !onPendingUserItem.DisplayName.IsNull() { - *displayName = onPendingUserItem.DisplayName.ValueString() - } else { - displayName = nil - } - email1 := new(string) - if !onPendingUserItem.Email.IsUnknown() && !onPendingUserItem.Email.IsNull() { - *email1 = onPendingUserItem.Email.ValueString() - } else { - email1 = nil - } - var imageURI *shared.ImageURI - if onPendingUserItem.ImageURI != nil { - key := new(string) - if !onPendingUserItem.ImageURI.Key.IsUnknown() && !onPendingUserItem.ImageURI.Key.IsNull() { - *key = onPendingUserItem.ImageURI.Key.ValueString() - } else { - key = nil - } - original := new(string) - if !onPendingUserItem.ImageURI.Original.IsUnknown() && !onPendingUserItem.ImageURI.Original.IsNull() { - *original = onPendingUserItem.ImageURI.Original.ValueString() - } else { - original = nil - } - thumbnail32 := new(string) - if !onPendingUserItem.ImageURI.Thumbnail32.IsUnknown() && !onPendingUserItem.ImageURI.Thumbnail32.IsNull() { - *thumbnail32 = onPendingUserItem.ImageURI.Thumbnail32.ValueString() - } else { - thumbnail32 = nil - } - thumbnail64 := new(string) - if !onPendingUserItem.ImageURI.Thumbnail64.IsUnknown() && !onPendingUserItem.ImageURI.Thumbnail64.IsNull() { - *thumbnail64 = onPendingUserItem.ImageURI.Thumbnail64.ValueString() - } else { - thumbnail64 = nil - } - imageURI = &shared.ImageURI{ - Key: key, - Original: original, - Thumbnail32: thumbnail32, - Thumbnail64: thumbnail64, - } - } - orgID := new(string) - if !onPendingUserItem.OrgID.IsUnknown() && !onPendingUserItem.OrgID.IsNull() { - *orgID = onPendingUserItem.OrgID.ValueString() - } else { - orgID = nil - } - phone := new(string) - if !onPendingUserItem.Phone.IsUnknown() && !onPendingUserItem.Phone.IsNull() { - *phone = onPendingUserItem.Phone.ValueString() - } else { - phone = nil - } - typeVar := new(string) - if !onPendingUserItem.Type.IsUnknown() && !onPendingUserItem.Type.IsNull() { - *typeVar = onPendingUserItem.Type.ValueString() - } else { - typeVar = nil - } - userID := new(string) - if !onPendingUserItem.UserID.IsUnknown() && !onPendingUserItem.UserID.IsNull() { - *userID = onPendingUserItem.UserID.ValueString() - } else { - userID = nil - } - onPendingUser = append(onPendingUser, shared.AdminUser{ - AdditionalProperties: additionalProperties, - DisplayName: displayName, - Email: email1, - ImageURI: imageURI, - OrgID: orgID, - Phone: phone, - Type: typeVar, - UserID: userID, - }) - } - defaultUserToNotify = &shared.UpsertPortalConfigV3DefaultUserToNotify{ - OnPendingUser: onPendingUser, - } - } - designID := new(string) - if !r.DesignID.IsUnknown() && !r.DesignID.IsNull() { - *designID = r.DesignID.ValueString() - } else { - designID = nil - } - domain := new(string) - if !r.Domain.IsUnknown() && !r.Domain.IsNull() { - *domain = r.Domain.ValueString() - } else { - domain = nil - } - var emailTemplates *shared.EmailTemplates - if r.EmailTemplates != nil { - advancedAuth := new(string) - if !r.EmailTemplates.AdvancedAuth.IsUnknown() && !r.EmailTemplates.AdvancedAuth.IsNull() { - *advancedAuth = r.EmailTemplates.AdvancedAuth.ValueString() - } else { - advancedAuth = nil - } - advancedMFA := new(string) - if !r.EmailTemplates.AdvancedMFA.IsUnknown() && !r.EmailTemplates.AdvancedMFA.IsNull() { - *advancedMFA = r.EmailTemplates.AdvancedMFA.ValueString() - } else { - advancedMFA = nil - } - confirmAccount := new(string) - if !r.EmailTemplates.ConfirmAccount.IsUnknown() && !r.EmailTemplates.ConfirmAccount.IsNull() { - *confirmAccount = r.EmailTemplates.ConfirmAccount.ValueString() - } else { - confirmAccount = nil - } - confirmEmailUpdate := new(string) - if !r.EmailTemplates.ConfirmEmailUpdate.IsUnknown() && !r.EmailTemplates.ConfirmEmailUpdate.IsNull() { - *confirmEmailUpdate = r.EmailTemplates.ConfirmEmailUpdate.ValueString() - } else { - confirmEmailUpdate = nil - } - forgotPassword := new(string) - if !r.EmailTemplates.ForgotPassword.IsUnknown() && !r.EmailTemplates.ForgotPassword.IsNull() { - *forgotPassword = r.EmailTemplates.ForgotPassword.ValueString() - } else { - forgotPassword = nil - } - invitation := new(string) - if !r.EmailTemplates.Invitation.IsUnknown() && !r.EmailTemplates.Invitation.IsNull() { - *invitation = r.EmailTemplates.Invitation.ValueString() - } else { - invitation = nil - } - journeyLoginOTP := new(string) - if !r.EmailTemplates.JourneyLoginOTP.IsUnknown() && !r.EmailTemplates.JourneyLoginOTP.IsNull() { - *journeyLoginOTP = r.EmailTemplates.JourneyLoginOTP.ValueString() - } else { - journeyLoginOTP = nil - } - journeySignInOneTimePassword := new(string) - if !r.EmailTemplates.JourneySignInOneTimePassword.IsUnknown() && !r.EmailTemplates.JourneySignInOneTimePassword.IsNull() { - *journeySignInOneTimePassword = r.EmailTemplates.JourneySignInOneTimePassword.ValueString() - } else { - journeySignInOneTimePassword = nil - } - journeySignUp := new(string) - if !r.EmailTemplates.JourneySignUp.IsUnknown() && !r.EmailTemplates.JourneySignUp.IsNull() { - *journeySignUp = r.EmailTemplates.JourneySignUp.ValueString() - } else { - journeySignUp = nil - } - onDocUpload := new(string) - if !r.EmailTemplates.OnDocUpload.IsUnknown() && !r.EmailTemplates.OnDocUpload.IsNull() { - *onDocUpload = r.EmailTemplates.OnDocUpload.ValueString() - } else { - onDocUpload = nil - } - onMapAPendingUser := new(string) - if !r.EmailTemplates.OnMapAPendingUser.IsUnknown() && !r.EmailTemplates.OnMapAPendingUser.IsNull() { - *onMapAPendingUser = r.EmailTemplates.OnMapAPendingUser.ValueString() - } else { - onMapAPendingUser = nil - } - onNewQuote := new(string) - if !r.EmailTemplates.OnNewQuote.IsUnknown() && !r.EmailTemplates.OnNewQuote.IsNull() { - *onNewQuote = r.EmailTemplates.OnNewQuote.ValueString() - } else { - onNewQuote = nil - } - onWorkflowStepAssigned := new(string) - if !r.EmailTemplates.OnWorkflowStepAssigned.IsUnknown() && !r.EmailTemplates.OnWorkflowStepAssigned.IsNull() { - *onWorkflowStepAssigned = r.EmailTemplates.OnWorkflowStepAssigned.ValueString() - } else { - onWorkflowStepAssigned = nil - } - verifyCodeToSetPassword := new(string) - if !r.EmailTemplates.VerifyCodeToSetPassword.IsUnknown() && !r.EmailTemplates.VerifyCodeToSetPassword.IsNull() { - *verifyCodeToSetPassword = r.EmailTemplates.VerifyCodeToSetPassword.ValueString() - } else { - verifyCodeToSetPassword = nil - } - emailTemplates = &shared.EmailTemplates{ - AdvancedAuth: advancedAuth, - AdvancedMFA: advancedMFA, - ConfirmAccount: confirmAccount, - ConfirmEmailUpdate: confirmEmailUpdate, - ForgotPassword: forgotPassword, - Invitation: invitation, - JourneyLoginOTP: journeyLoginOTP, - JourneySignInOneTimePassword: journeySignInOneTimePassword, - JourneySignUp: journeySignUp, - OnDocUpload: onDocUpload, - OnMapAPendingUser: onMapAPendingUser, - OnNewQuote: onNewQuote, - OnWorkflowStepAssigned: onWorkflowStepAssigned, - VerifyCodeToSetPassword: verifyCodeToSetPassword, - } - } - enabled2 := new(bool) - if !r.Enabled.IsUnknown() && !r.Enabled.IsNull() { - *enabled2 = r.Enabled.ValueBool() - } else { - enabled2 = nil - } - entityActions := make([]shared.UpsertPortalConfigV3EntityActions, 0, len(r.EntityActions)) - for _, entityActionsItem := range r.EntityActions { - var actionLabel *shared.UpsertPortalConfigV3ActionLabel - if entityActionsItem.ActionLabel != nil { - de := new(string) - if !entityActionsItem.ActionLabel.De.IsUnknown() && !entityActionsItem.ActionLabel.De.IsNull() { - *de = entityActionsItem.ActionLabel.De.ValueString() - } else { - de = nil - } - en := new(string) - if !entityActionsItem.ActionLabel.En.IsUnknown() && !entityActionsItem.ActionLabel.En.IsNull() { - *en = entityActionsItem.ActionLabel.En.ValueString() - } else { - en = nil - } - actionLabel = &shared.UpsertPortalConfigV3ActionLabel{ - De: de, - En: en, - } - } - journeyID := new(string) - if !entityActionsItem.JourneyID.IsUnknown() && !entityActionsItem.JourneyID.IsNull() { - *journeyID = entityActionsItem.JourneyID.ValueString() - } else { - journeyID = nil - } - slug := new(shared.EntitySlug) - if !entityActionsItem.Slug.IsUnknown() && !entityActionsItem.Slug.IsNull() { - *slug = shared.EntitySlug(entityActionsItem.Slug.ValueString()) - } else { - slug = nil - } - entityActions = append(entityActions, shared.UpsertPortalConfigV3EntityActions{ - ActionLabel: actionLabel, - JourneyID: journeyID, - Slug: slug, - }) - } - var entityEditRules interface{} - if !r.EntityEditRules.IsUnknown() && !r.EntityEditRules.IsNull() { - _ = json.Unmarshal([]byte(r.EntityEditRules.ValueString()), &entityEditRules) - } - var entityIdentifiers *shared.UpsertPortalConfigV3EntityIdentifiers - if r.EntityIdentifiers != nil { - var typeVar1 *shared.UpsertPortalConfigV3Type - if r.EntityIdentifiers.Type != nil { - attributes := make([]string, 0, len(r.EntityIdentifiers.Type.Attributes)) - for _, attributesItem := range r.EntityIdentifiers.Type.Attributes { - attributes = append(attributes, attributesItem.ValueString()) - } - isEnabled := new(bool) - if !r.EntityIdentifiers.Type.IsEnabled.IsUnknown() && !r.EntityIdentifiers.Type.IsEnabled.IsNull() { - *isEnabled = r.EntityIdentifiers.Type.IsEnabled.ValueBool() - } else { - isEnabled = nil - } - typeVar1 = &shared.UpsertPortalConfigV3Type{ - Attributes: attributes, - IsEnabled: isEnabled, - } - } - entityIdentifiers = &shared.UpsertPortalConfigV3EntityIdentifiers{ - Type: typeVar1, - } - } - extensionHooks := make(map[string]*shared.ExtensionHookConfig) - for extensionHooksKey, extensionHooksValue := range r.ExtensionHooks { - var extensionHooksInst *shared.ExtensionHookConfig - appID := new(string) - if !extensionHooksValue.AppID.IsUnknown() && !extensionHooksValue.AppID.IsNull() { - *appID = extensionHooksValue.AppID.ValueString() - } else { - appID = nil - } - hookID := new(string) - if !extensionHooksValue.HookID.IsUnknown() && !extensionHooksValue.HookID.IsNull() { - *hookID = extensionHooksValue.HookID.ValueString() - } else { - hookID = nil - } - extensionHooksInst = &shared.ExtensionHookConfig{ - AppID: appID, - HookID: hookID, - } - extensionHooks[extensionHooksKey] = extensionHooksInst - } - extensions := make([]shared.ExtensionConfig, 0, len(r.Extensions)) - for _, extensionsItem := range r.Extensions { - var id string - id = extensionsItem.ID.ValueString() - - optionsVar := make(map[string]string) - for optionsKey, optionsValue := range extensionsItem.Options { - var optionsInst string - optionsInst = optionsValue.ValueString() - - optionsVar[optionsKey] = optionsInst - } - status := new(shared.ExtensionConfigStatus) - if !extensionsItem.Status.IsUnknown() && !extensionsItem.Status.IsNull() { - *status = shared.ExtensionConfigStatus(extensionsItem.Status.ValueString()) - } else { - status = nil - } - extensions = append(extensions, shared.ExtensionConfig{ - ID: id, - Options: optionsVar, - Status: status, - }) - } - var featureSettings *shared.UpsertPortalConfigV3FeatureSettings - if r.FeatureSettings != nil { - billing := new(bool) - if !r.FeatureSettings.Billing.IsUnknown() && !r.FeatureSettings.Billing.IsNull() { - *billing = r.FeatureSettings.Billing.ValueBool() - } else { - billing = nil - } - changeDueDate := new(bool) - if !r.FeatureSettings.ChangeDueDate.IsUnknown() && !r.FeatureSettings.ChangeDueDate.IsNull() { - *changeDueDate = r.FeatureSettings.ChangeDueDate.ValueBool() - } else { - changeDueDate = nil - } - newDesign := new(bool) - if !r.FeatureSettings.NewDesign.IsUnknown() && !r.FeatureSettings.NewDesign.IsNull() { - *newDesign = r.FeatureSettings.NewDesign.ValueBool() - } else { - newDesign = nil - } - startPage := new(bool) - if !r.FeatureSettings.StartPage.IsUnknown() && !r.FeatureSettings.StartPage.IsNull() { - *startPage = r.FeatureSettings.StartPage.ValueBool() - } else { - startPage = nil - } - featureSettings = &shared.UpsertPortalConfigV3FeatureSettings{ - Billing: billing, - ChangeDueDate: changeDueDate, - NewDesign: newDesign, - StartPage: startPage, - } - } - var images *shared.UpsertPortalConfigV3Images - if r.Images != nil { - orderLeftTeaser := new(string) - if !r.Images.OrderLeftTeaser.IsUnknown() && !r.Images.OrderLeftTeaser.IsNull() { - *orderLeftTeaser = r.Images.OrderLeftTeaser.ValueString() - } else { - orderLeftTeaser = nil - } - orderRightTeaser := new(string) - if !r.Images.OrderRightTeaser.IsUnknown() && !r.Images.OrderRightTeaser.IsNull() { - *orderRightTeaser = r.Images.OrderRightTeaser.ValueString() - } else { - orderRightTeaser = nil - } - welcomeBanner := new(string) - if !r.Images.WelcomeBanner.IsUnknown() && !r.Images.WelcomeBanner.IsNull() { - *welcomeBanner = r.Images.WelcomeBanner.ValueString() - } else { - welcomeBanner = nil - } - images = &shared.UpsertPortalConfigV3Images{ - OrderLeftTeaser: orderLeftTeaser, - OrderRightTeaser: orderRightTeaser, - WelcomeBanner: welcomeBanner, - } - } - inactiveContractCutoffYears := new(float64) - if !r.InactiveContractCutoffYears.IsUnknown() && !r.InactiveContractCutoffYears.IsNull() { - *inactiveContractCutoffYears = r.InactiveContractCutoffYears.ValueFloat64() - } else { - inactiveContractCutoffYears = nil - } - isDummy := new(bool) - if !r.IsDummy.IsUnknown() && !r.IsDummy.IsNull() { - *isDummy = r.IsDummy.ValueBool() - } else { - isDummy = nil - } - isEpilotDomain := new(bool) - if !r.IsEpilotDomain.IsUnknown() && !r.IsEpilotDomain.IsNull() { - *isEpilotDomain = r.IsEpilotDomain.ValueBool() - } else { - isEpilotDomain = nil - } - isV3Item := new(bool) - if !r.IsV3Item.IsUnknown() && !r.IsV3Item.IsNull() { - *isV3Item = r.IsV3Item.ValueBool() - } else { - isV3Item = nil - } - meterReadingGracePeriod := new(float64) - if !r.MeterReadingGracePeriod.IsUnknown() && !r.MeterReadingGracePeriod.IsNull() { - *meterReadingGracePeriod = r.MeterReadingGracePeriod.ValueFloat64() - } else { - meterReadingGracePeriod = nil - } - name := new(string) - if !r.Name.IsUnknown() && !r.Name.IsNull() { - *name = r.Name.ValueString() - } else { - name = nil - } - origin := new(string) - if !r.Origin.IsUnknown() && !r.Origin.IsNull() { - *origin = r.Origin.ValueString() - } else { - origin = nil - } - var pages interface{} - if !r.Pages.IsUnknown() && !r.Pages.IsNull() { - _ = json.Unmarshal([]byte(r.Pages.ValueString()), &pages) - } - portalID := new(string) - if !r.PortalID.IsUnknown() && !r.PortalID.IsNull() { - *portalID = r.PortalID.ValueString() - } else { - portalID = nil - } - portalSkV3 := new(string) - if !r.PortalSkV3.IsUnknown() && !r.PortalSkV3.IsNull() { - *portalSkV3 = r.PortalSkV3.ValueString() - } else { - portalSkV3 = nil - } - preventSearchEngineIndexing := new(bool) - if !r.PreventSearchEngineIndexing.IsUnknown() && !r.PreventSearchEngineIndexing.IsNull() { - *preventSearchEngineIndexing = r.PreventSearchEngineIndexing.ValueBool() - } else { - preventSearchEngineIndexing = nil - } - var registrationIdentifiers interface{} - if !r.RegistrationIdentifiers.IsUnknown() && !r.RegistrationIdentifiers.IsNull() { - _ = json.Unmarshal([]byte(r.RegistrationIdentifiers.ValueString()), ®istrationIdentifiers) - } - selfRegistrationSetting := new(shared.UpsertPortalConfigV3SelfRegistrationSetting) - if !r.SelfRegistrationSetting.IsUnknown() && !r.SelfRegistrationSetting.IsNull() { - *selfRegistrationSetting = shared.UpsertPortalConfigV3SelfRegistrationSetting(r.SelfRegistrationSetting.ValueString()) - } else { - selfRegistrationSetting = nil - } - triggeredJourneys := make([]shared.UpsertPortalConfigV3TriggeredJourneys, 0, len(r.TriggeredJourneys)) - for _, triggeredJourneysItem := range r.TriggeredJourneys { - journeyId1 := new(string) - if !triggeredJourneysItem.JourneyID.IsUnknown() && !triggeredJourneysItem.JourneyID.IsNull() { - *journeyId1 = triggeredJourneysItem.JourneyID.ValueString() - } else { - journeyId1 = nil - } - triggerName := new(shared.UpsertPortalConfigV3TriggerName) - if !triggeredJourneysItem.TriggerName.IsUnknown() && !triggeredJourneysItem.TriggerName.IsNull() { - *triggerName = shared.UpsertPortalConfigV3TriggerName(triggeredJourneysItem.TriggerName.ValueString()) - } else { - triggerName = nil - } - triggeredJourneys = append(triggeredJourneys, shared.UpsertPortalConfigV3TriggeredJourneys{ - JourneyID: journeyId1, - TriggerName: triggerName, - }) - } - out := shared.UpsertPortalConfigV3{ - AccessToken: accessToken, - AdvancedMfa: advancedMfa, - AllowedFileExtensions: allowedFileExtensions, - ApprovalStateAttributes: approvalStateAttributes, - AuthSettings: authSettings, - CognitoDetails: cognitoDetails, - Config: config, - ContactIdentifiers: contactIdentifiers, - ContractIdentifiers: contractIdentifiers, - ContractSelectorConfig: contractSelectorConfig, - DefaultUserToNotify: defaultUserToNotify, - DesignID: designID, - Domain: domain, - EmailTemplates: emailTemplates, - Enabled: enabled2, - EntityActions: entityActions, - EntityEditRules: entityEditRules, - EntityIdentifiers: entityIdentifiers, - ExtensionHooks: extensionHooks, - Extensions: extensions, - FeatureSettings: featureSettings, - Images: images, - InactiveContractCutoffYears: inactiveContractCutoffYears, - IsDummy: isDummy, - IsEpilotDomain: isEpilotDomain, - IsV3Item: isV3Item, - MeterReadingGracePeriod: meterReadingGracePeriod, - Name: name, - Origin: origin, - Pages: pages, - PortalID: portalID, - PortalSkV3: portalSkV3, - PreventSearchEngineIndexing: preventSearchEngineIndexing, - RegistrationIdentifiers: registrationIdentifiers, - SelfRegistrationSetting: selfRegistrationSetting, - TriggeredJourneys: triggeredJourneys, - } - - return &out, diags -} diff --git a/internal/provider/portalpage_data_source.go b/internal/provider/portalpage_data_source.go deleted file mode 100644 index 3e9ac25..0000000 --- a/internal/provider/portalpage_data_source.go +++ /dev/null @@ -1,255 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "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 = &PortalPageDataSource{} -var _ datasource.DataSourceWithConfigure = &PortalPageDataSource{} - -func NewPortalPageDataSource() datasource.DataSource { - return &PortalPageDataSource{} -} - -// PortalPageDataSource is the data source implementation. -type PortalPageDataSource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// PortalPageDataSourceModel describes the data model. -type PortalPageDataSourceModel struct { - AdditionalProperties jsontypes.Normalized `tfsdk:"additional_properties"` - Blocks map[string]tfTypes.Block `tfsdk:"blocks"` - Content map[string]jsontypes.Normalized `tfsdk:"content"` - Design map[string]jsontypes.Normalized `tfsdk:"design"` - ID types.String `tfsdk:"id"` - IsDeleted types.Bool `tfsdk:"is_deleted"` - IsEntryRoute types.Bool `tfsdk:"is_entry_route"` - IsPublic types.Bool `tfsdk:"is_public"` - IsSystem types.Bool `tfsdk:"is_system"` - LastModifiedAt types.String `tfsdk:"last_modified_at"` - Order types.Float64 `tfsdk:"order"` - ParentID types.String `tfsdk:"parent_id"` - Path types.String `tfsdk:"path"` - Schema []types.String `tfsdk:"schema"` - Slug types.String `tfsdk:"slug"` - Visibility map[string]jsontypes.Normalized `tfsdk:"visibility"` -} - -// Metadata returns the data source type name. -func (r *PortalPageDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_portal_page" -} - -// Schema defines the schema for the data source. -func (r *PortalPageDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "PortalPage DataSource", - - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "blocks": schema.MapNestedAttribute{ - Computed: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `The id of the block`, - }, - "order": schema.Float64Attribute{ - Computed: true, - Description: `The order of the block`, - }, - "parent_id": schema.StringAttribute{ - Computed: true, - Description: `The id of the parent block`, - }, - "props": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Description: `Parsed as JSON.`, - }, - "content": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The content of the block`, - }, - "design": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The design of the block`, - }, - "visibility": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The conditions that need to be met for the block to be shown`, - }, - }, - }, - "type": schema.StringAttribute{ - Computed: true, - Description: `The type of the block. eg; tabs, tab, group, attribute`, - }, - }, - }, - }, - "content": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The content of the page`, - }, - "design": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The design of the page`, - }, - "id": schema.StringAttribute{ - Required: true, - }, - "is_deleted": schema.BoolAttribute{ - Computed: true, - Description: `Send the flag as true to delete the page`, - }, - "is_entry_route": schema.BoolAttribute{ - Computed: true, - Description: `Whether the page is the entry route`, - }, - "is_public": schema.BoolAttribute{ - Computed: true, - Description: `Whether the page is public`, - }, - "is_system": schema.BoolAttribute{ - Computed: true, - Description: `Whether the page is a system page`, - }, - "last_modified_at": schema.StringAttribute{ - Computed: true, - Description: `Last modified timestamp of the Page`, - }, - "order": schema.Float64Attribute{ - Computed: true, - Description: `The order of the block`, - }, - "parent_id": schema.StringAttribute{ - Computed: true, - Description: `The id of the parent page`, - }, - "path": schema.StringAttribute{ - Computed: true, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `The path of the page`, - }, - "schema": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "slug": schema.StringAttribute{ - Computed: true, - Description: `The slug of the page`, - }, - "visibility": schema.MapAttribute{ - Computed: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The conditions that need to be met for the page to be shown`, - }, - }, - } -} - -func (r *PortalPageDataSource) 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 *PortalPageDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data *PortalPageDataSourceModel - 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 - } - - request, requestDiags := data.ToOperationsGetPortalPageRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.GetPortalPage(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.Page != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPage(ctx, res.Page)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} diff --git a/internal/provider/portalpage_data_source_sdk.go b/internal/provider/portalpage_data_source_sdk.go deleted file mode 100644 index 0d72982..0000000 --- a/internal/provider/portalpage_data_source_sdk.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/typeconvert" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *PortalPageDataSourceModel) RefreshFromSharedPage(ctx context.Context, resp *shared.Page) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - if resp.AdditionalProperties == nil { - r.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.AdditionalProperties) - r.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult)) - } - if len(resp.Blocks) > 0 { - r.Blocks = make(map[string]tfTypes.Block, len(resp.Blocks)) - for blockKey, blockValue := range resp.Blocks { - var blockResult tfTypes.Block - if blockValue.AdditionalProperties == nil { - blockResult.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult1, _ := json.Marshal(blockValue.AdditionalProperties) - blockResult.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult1)) - } - blockResult.ID = types.StringPointerValue(blockValue.ID) - blockResult.Order = types.Float64Value(blockValue.Order) - blockResult.ParentID = types.StringPointerValue(blockValue.ParentID) - if blockValue.Props == nil { - blockResult.Props = nil - } else { - blockResult.Props = &tfTypes.BlockProps{} - if blockValue.Props.AdditionalProperties == nil { - blockResult.Props.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult2, _ := json.Marshal(blockValue.Props.AdditionalProperties) - blockResult.Props.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult2)) - } - if len(blockValue.Props.Content) > 0 { - blockResult.Props.Content = make(map[string]jsontypes.Normalized, len(blockValue.Props.Content)) - for key, value := range blockValue.Props.Content { - result, _ := json.Marshal(value) - blockResult.Props.Content[key] = jsontypes.NewNormalizedValue(string(result)) - } - } - if len(blockValue.Props.Design) > 0 { - blockResult.Props.Design = make(map[string]jsontypes.Normalized, len(blockValue.Props.Design)) - for key1, value1 := range blockValue.Props.Design { - result1, _ := json.Marshal(value1) - blockResult.Props.Design[key1] = jsontypes.NewNormalizedValue(string(result1)) - } - } - if len(blockValue.Props.Visibility) > 0 { - blockResult.Props.Visibility = make(map[string]jsontypes.Normalized, len(blockValue.Props.Visibility)) - for key2, value2 := range blockValue.Props.Visibility { - result2, _ := json.Marshal(value2) - blockResult.Props.Visibility[key2] = jsontypes.NewNormalizedValue(string(result2)) - } - } - } - blockResult.Type = types.StringValue(blockValue.Type) - - r.Blocks[blockKey] = blockResult - } - } - if len(resp.Content) > 0 { - r.Content = make(map[string]jsontypes.Normalized, len(resp.Content)) - for key3, value3 := range resp.Content { - result3, _ := json.Marshal(value3) - r.Content[key3] = jsontypes.NewNormalizedValue(string(result3)) - } - } - if len(resp.Design) > 0 { - r.Design = make(map[string]jsontypes.Normalized, len(resp.Design)) - for key4, value4 := range resp.Design { - result4, _ := json.Marshal(value4) - r.Design[key4] = jsontypes.NewNormalizedValue(string(result4)) - } - } - r.ID = types.StringPointerValue(resp.ID) - r.IsDeleted = types.BoolPointerValue(resp.IsDeleted) - r.IsEntryRoute = types.BoolPointerValue(resp.IsEntryRoute) - r.IsPublic = types.BoolPointerValue(resp.IsPublic) - r.IsSystem = types.BoolPointerValue(resp.IsSystem) - r.LastModifiedAt = types.StringPointerValue(typeconvert.TimePointerToStringPointer(resp.LastModifiedAt)) - r.Order = types.Float64Value(resp.Order) - r.ParentID = types.StringPointerValue(resp.ParentID) - r.Path = types.StringPointerValue(resp.Path) - r.Schema = make([]types.String, 0, len(resp.Schema)) - for _, v := range resp.Schema { - r.Schema = append(r.Schema, types.StringValue(string(v))) - } - r.Slug = types.StringValue(resp.Slug) - if len(resp.Visibility) > 0 { - r.Visibility = make(map[string]jsontypes.Normalized, len(resp.Visibility)) - for key5, value5 := range resp.Visibility { - result5, _ := json.Marshal(value5) - r.Visibility[key5] = jsontypes.NewNormalizedValue(string(result5)) - } - } - } - - return diags -} - -func (r *PortalPageDataSourceModel) ToOperationsGetPortalPageRequest(ctx context.Context) (*operations.GetPortalPageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var id string - id = r.ID.ValueString() - - out := operations.GetPortalPageRequest{ - ID: id, - } - - return &out, diags -} diff --git a/internal/provider/portalpage_resource.go b/internal/provider/portalpage_resource.go deleted file mode 100644 index 99c971b..0000000 --- a/internal/provider/portalpage_resource.go +++ /dev/null @@ -1,526 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "fmt" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators" - speakeasy_float64validators "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators/float64validators" - speakeasy_objectvalidators "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators/objectvalidators" - speakeasy_stringvalidators "github.com/epilot-dev/terraform-provider-epilot-portal/internal/validators/stringvalidators" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "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 _ resource.Resource = &PortalPageResource{} -var _ resource.ResourceWithImportState = &PortalPageResource{} - -func NewPortalPageResource() resource.Resource { - return &PortalPageResource{} -} - -// PortalPageResource defines the resource implementation. -type PortalPageResource struct { - // Provider configured SDK client. - client *sdk.SDK -} - -// PortalPageResourceModel describes the resource data model. -type PortalPageResourceModel struct { - AdditionalProperties jsontypes.Normalized `tfsdk:"additional_properties"` - Blocks map[string]tfTypes.Block `tfsdk:"blocks"` - Content map[string]jsontypes.Normalized `tfsdk:"content"` - Design map[string]jsontypes.Normalized `tfsdk:"design"` - Domain types.String `queryParam:"style=form,explode=true,name=domain" tfsdk:"domain"` - ID types.String `tfsdk:"id"` - IsDeleted types.Bool `tfsdk:"is_deleted"` - IsEntryRoute types.Bool `tfsdk:"is_entry_route"` - IsPublic types.Bool `tfsdk:"is_public"` - IsSystem types.Bool `tfsdk:"is_system"` - LastModifiedAt types.String `tfsdk:"last_modified_at"` - Order types.Float64 `tfsdk:"order"` - ParentID types.String `tfsdk:"parent_id"` - Path types.String `tfsdk:"path"` - Schema []types.String `tfsdk:"schema"` - Slug types.String `tfsdk:"slug"` - Visibility map[string]jsontypes.Normalized `tfsdk:"visibility"` -} - -func (r *PortalPageResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_portal_page" -} - -func (r *PortalPageResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = schema.Schema{ - MarkdownDescription: "PortalPage Resource", - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "blocks": schema.MapNestedAttribute{ - Computed: true, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Validators: []validator.Object{ - speakeasy_objectvalidators.NotNull(), - }, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the block`, - }, - "order": schema.Float64Attribute{ - Computed: true, - Optional: true, - Description: `The order of the block. Not Null`, - Validators: []validator.Float64{ - speakeasy_float64validators.NotNull(), - }, - }, - "parent_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the parent block`, - }, - "props": schema.SingleNestedAttribute{ - Computed: true, - Optional: true, - Attributes: map[string]schema.Attribute{ - "additional_properties": schema.StringAttribute{ - CustomType: jsontypes.NormalizedType{}, - Computed: true, - Optional: true, - Description: `Parsed as JSON.`, - }, - "content": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The content of the block`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "design": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The design of the block`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "visibility": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The conditions that need to be met for the block to be shown`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - }, - }, - "type": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The type of the block. eg; tabs, tab, group, attribute. Not Null`, - Validators: []validator.String{ - speakeasy_stringvalidators.NotNull(), - }, - }, - }, - }, - }, - "content": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The content of the page`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "design": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The design of the page`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - "domain": schema.StringAttribute{ - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplaceIfConfigured(), - }, - Description: `Requires replacement if changed.`, - }, - "id": schema.StringAttribute{ - Computed: true, - Description: `The id of the page`, - }, - "is_deleted": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Send the flag as true to delete the page`, - }, - "is_entry_route": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether the page is the entry route`, - }, - "is_public": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether the page is public`, - }, - "is_system": schema.BoolAttribute{ - Computed: true, - Optional: true, - Description: `Whether the page is a system page`, - }, - "last_modified_at": schema.StringAttribute{ - Computed: true, - Description: `Last modified timestamp of the Page`, - Validators: []validator.String{ - validators.IsRFC3339(), - }, - }, - "order": schema.Float64Attribute{ - Required: true, - Description: `The order of the block`, - }, - "parent_id": schema.StringAttribute{ - Computed: true, - Optional: true, - Description: `The id of the parent page`, - }, - "path": schema.StringAttribute{ - Computed: true, - Optional: true, - DeprecationMessage: `This will be removed in a future release, please migrate away from it as soon as possible`, - Description: `The path of the page`, - }, - "schema": schema.ListAttribute{ - Computed: true, - Optional: true, - ElementType: types.StringType, - }, - "slug": schema.StringAttribute{ - Required: true, - Description: `The slug of the page`, - }, - "visibility": schema.MapAttribute{ - Computed: true, - Optional: true, - ElementType: jsontypes.NormalizedType{}, - Description: `The conditions that need to be met for the page to be shown`, - Validators: []validator.Map{ - mapvalidator.ValueStringsAre(validators.IsValidJSON()), - }, - }, - }, - } -} - -func (r *PortalPageResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.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 Resource 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 *PortalPageResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var data *PortalPageResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ - UnhandledNullAsEmpty: true, - UnhandledUnknownAsEmpty: true, - })...) - - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsCreatePortalPageRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.CreatePortalPage(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.Page != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPage(ctx, res.Page)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - request1, request1Diags := data.ToOperationsGetPortalPageRequest(ctx) - resp.Diagnostics.Append(request1Diags...) - - if resp.Diagnostics.HasError() { - return - } - res1, err := r.client.ECPAdmin.GetPortalPage(ctx, *request1) - if err != nil { - resp.Diagnostics.AddError("failure to invoke API", err.Error()) - if res1 != nil && res1.RawResponse != nil { - resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) - } - return - } - if res1 == nil { - resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) - return - } - if res1.StatusCode != 200 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) - return - } - if !(res1.Page != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res1.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPage(ctx, res1.Page)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalPageResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *PortalPageResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.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 - } - - request, requestDiags := data.ToOperationsGetPortalPageRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.GetPortalPage(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 == 404 { - resp.State.RemoveResource(ctx) - 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.Page != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPage(ctx, res.Page)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalPageResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var data *PortalPageResourceModel - var plan types.Object - - resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) - if resp.Diagnostics.HasError() { - return - } - - merge(ctx, req, resp, &data) - if resp.Diagnostics.HasError() { - return - } - - request, requestDiags := data.ToOperationsUpdatePortalPageRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.UpdatePortalPage(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.Page != nil) { - resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) - return - } - resp.Diagnostics.Append(data.RefreshFromSharedPage(ctx, res.Page)...) - - if resp.Diagnostics.HasError() { - return - } - - resp.Diagnostics.Append(refreshPlan(ctx, plan, &data)...) - - if resp.Diagnostics.HasError() { - return - } - - // Save updated data into Terraform state - resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) -} - -func (r *PortalPageResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *PortalPageResourceModel - var item types.Object - - resp.Diagnostics.Append(req.State.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 - } - - request, requestDiags := data.ToOperationsDeletePortalPageRequest(ctx) - resp.Diagnostics.Append(requestDiags...) - - if resp.Diagnostics.HasError() { - return - } - res, err := r.client.ECPAdmin.DeletePortalPage(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 != 204 { - resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) - return - } - -} - -func (r *PortalPageResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("id"), req.ID)...) -} diff --git a/internal/provider/portalpage_resource_sdk.go b/internal/provider/portalpage_resource_sdk.go deleted file mode 100644 index 60a3ca2..0000000 --- a/internal/provider/portalpage_resource_sdk.go +++ /dev/null @@ -1,339 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package provider - -import ( - "context" - "encoding/json" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/typeconvert" - tfTypes "github.com/epilot-dev/terraform-provider-epilot-portal/internal/provider/types" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/diag" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -func (r *PortalPageResourceModel) RefreshFromSharedPage(ctx context.Context, resp *shared.Page) diag.Diagnostics { - var diags diag.Diagnostics - - if resp != nil { - if resp.AdditionalProperties == nil { - r.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult, _ := json.Marshal(resp.AdditionalProperties) - r.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult)) - } - if len(resp.Blocks) > 0 { - r.Blocks = make(map[string]tfTypes.Block, len(resp.Blocks)) - for blockKey, blockValue := range resp.Blocks { - var blockResult tfTypes.Block - if blockValue.AdditionalProperties == nil { - blockResult.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult1, _ := json.Marshal(blockValue.AdditionalProperties) - blockResult.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult1)) - } - blockResult.ID = types.StringPointerValue(blockValue.ID) - blockResult.Order = types.Float64Value(blockValue.Order) - blockResult.ParentID = types.StringPointerValue(blockValue.ParentID) - if blockValue.Props == nil { - blockResult.Props = nil - } else { - blockResult.Props = &tfTypes.BlockProps{} - if blockValue.Props.AdditionalProperties == nil { - blockResult.Props.AdditionalProperties = jsontypes.NewNormalizedNull() - } else { - additionalPropertiesResult2, _ := json.Marshal(blockValue.Props.AdditionalProperties) - blockResult.Props.AdditionalProperties = jsontypes.NewNormalizedValue(string(additionalPropertiesResult2)) - } - if len(blockValue.Props.Content) > 0 { - blockResult.Props.Content = make(map[string]jsontypes.Normalized, len(blockValue.Props.Content)) - for key, value := range blockValue.Props.Content { - result, _ := json.Marshal(value) - blockResult.Props.Content[key] = jsontypes.NewNormalizedValue(string(result)) - } - } - if len(blockValue.Props.Design) > 0 { - blockResult.Props.Design = make(map[string]jsontypes.Normalized, len(blockValue.Props.Design)) - for key1, value1 := range blockValue.Props.Design { - result1, _ := json.Marshal(value1) - blockResult.Props.Design[key1] = jsontypes.NewNormalizedValue(string(result1)) - } - } - if len(blockValue.Props.Visibility) > 0 { - blockResult.Props.Visibility = make(map[string]jsontypes.Normalized, len(blockValue.Props.Visibility)) - for key2, value2 := range blockValue.Props.Visibility { - result2, _ := json.Marshal(value2) - blockResult.Props.Visibility[key2] = jsontypes.NewNormalizedValue(string(result2)) - } - } - } - blockResult.Type = types.StringValue(blockValue.Type) - - r.Blocks[blockKey] = blockResult - } - } - if len(resp.Content) > 0 { - r.Content = make(map[string]jsontypes.Normalized, len(resp.Content)) - for key3, value3 := range resp.Content { - result3, _ := json.Marshal(value3) - r.Content[key3] = jsontypes.NewNormalizedValue(string(result3)) - } - } - if len(resp.Design) > 0 { - r.Design = make(map[string]jsontypes.Normalized, len(resp.Design)) - for key4, value4 := range resp.Design { - result4, _ := json.Marshal(value4) - r.Design[key4] = jsontypes.NewNormalizedValue(string(result4)) - } - } - r.ID = types.StringPointerValue(resp.ID) - r.IsDeleted = types.BoolPointerValue(resp.IsDeleted) - r.IsEntryRoute = types.BoolPointerValue(resp.IsEntryRoute) - r.IsPublic = types.BoolPointerValue(resp.IsPublic) - r.IsSystem = types.BoolPointerValue(resp.IsSystem) - r.LastModifiedAt = types.StringPointerValue(typeconvert.TimePointerToStringPointer(resp.LastModifiedAt)) - r.Order = types.Float64Value(resp.Order) - r.ParentID = types.StringPointerValue(resp.ParentID) - r.Path = types.StringPointerValue(resp.Path) - r.Schema = make([]types.String, 0, len(resp.Schema)) - for _, v := range resp.Schema { - r.Schema = append(r.Schema, types.StringValue(string(v))) - } - r.Slug = types.StringValue(resp.Slug) - if len(resp.Visibility) > 0 { - r.Visibility = make(map[string]jsontypes.Normalized, len(resp.Visibility)) - for key5, value5 := range resp.Visibility { - result5, _ := json.Marshal(value5) - r.Visibility[key5] = jsontypes.NewNormalizedValue(string(result5)) - } - } - } - - return diags -} - -func (r *PortalPageResourceModel) ToOperationsCreatePortalPageRequest(ctx context.Context) (*operations.CreatePortalPageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - pageRequest, pageRequestDiags := r.ToSharedPageRequest(ctx) - diags.Append(pageRequestDiags...) - - if diags.HasError() { - return nil, diags - } - - var domain string - domain = r.Domain.ValueString() - - out := operations.CreatePortalPageRequest{ - PageRequest: *pageRequest, - Domain: domain, - } - - return &out, diags -} - -func (r *PortalPageResourceModel) ToOperationsDeletePortalPageRequest(ctx context.Context) (*operations.DeletePortalPageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var id string - id = r.ID.ValueString() - - out := operations.DeletePortalPageRequest{ - ID: id, - } - - return &out, diags -} - -func (r *PortalPageResourceModel) ToOperationsGetPortalPageRequest(ctx context.Context) (*operations.GetPortalPageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var id string - id = r.ID.ValueString() - - out := operations.GetPortalPageRequest{ - ID: id, - } - - return &out, diags -} - -func (r *PortalPageResourceModel) ToOperationsUpdatePortalPageRequest(ctx context.Context) (*operations.UpdatePortalPageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - pageRequest, pageRequestDiags := r.ToSharedPageRequest(ctx) - diags.Append(pageRequestDiags...) - - if diags.HasError() { - return nil, diags - } - - var id string - id = r.ID.ValueString() - - out := operations.UpdatePortalPageRequest{ - PageRequest: *pageRequest, - ID: id, - } - - return &out, diags -} - -func (r *PortalPageResourceModel) ToSharedPageRequest(ctx context.Context) (*shared.PageRequest, diag.Diagnostics) { - var diags diag.Diagnostics - - var additionalProperties interface{} - if !r.AdditionalProperties.IsUnknown() && !r.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(r.AdditionalProperties.ValueString()), &additionalProperties) - } - blocks := make(map[string]shared.Block) - for blocksKey, blocksValue := range r.Blocks { - var additionalProperties1 interface{} - if !blocksValue.AdditionalProperties.IsUnknown() && !blocksValue.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(blocksValue.AdditionalProperties.ValueString()), &additionalProperties1) - } - id := new(string) - if !blocksValue.ID.IsUnknown() && !blocksValue.ID.IsNull() { - *id = blocksValue.ID.ValueString() - } else { - id = nil - } - var order float64 - order = blocksValue.Order.ValueFloat64() - - parentID := new(string) - if !blocksValue.ParentID.IsUnknown() && !blocksValue.ParentID.IsNull() { - *parentID = blocksValue.ParentID.ValueString() - } else { - parentID = nil - } - var props *shared.BlockProps - if blocksValue.Props != nil { - var additionalProperties2 interface{} - if !blocksValue.Props.AdditionalProperties.IsUnknown() && !blocksValue.Props.AdditionalProperties.IsNull() { - _ = json.Unmarshal([]byte(blocksValue.Props.AdditionalProperties.ValueString()), &additionalProperties2) - } - content := make(map[string]interface{}) - for contentKey, contentValue := range blocksValue.Props.Content { - var contentInst interface{} - _ = json.Unmarshal([]byte(contentValue.ValueString()), &contentInst) - content[contentKey] = contentInst - } - design := make(map[string]interface{}) - for designKey, designValue := range blocksValue.Props.Design { - var designInst interface{} - _ = json.Unmarshal([]byte(designValue.ValueString()), &designInst) - design[designKey] = designInst - } - visibility := make(map[string]interface{}) - for visibilityKey, visibilityValue := range blocksValue.Props.Visibility { - var visibilityInst interface{} - _ = json.Unmarshal([]byte(visibilityValue.ValueString()), &visibilityInst) - visibility[visibilityKey] = visibilityInst - } - props = &shared.BlockProps{ - AdditionalProperties: additionalProperties2, - Content: content, - Design: design, - Visibility: visibility, - } - } - var typeVar string - typeVar = blocksValue.Type.ValueString() - - blocksInst := shared.Block{ - AdditionalProperties: additionalProperties1, - ID: id, - Order: order, - ParentID: parentID, - Props: props, - Type: typeVar, - } - blocks[blocksKey] = blocksInst - } - content1 := make(map[string]interface{}) - for contentKey1, contentValue1 := range r.Content { - var contentInst1 interface{} - _ = json.Unmarshal([]byte(contentValue1.ValueString()), &contentInst1) - content1[contentKey1] = contentInst1 - } - design1 := make(map[string]interface{}) - for designKey1, designValue1 := range r.Design { - var designInst1 interface{} - _ = json.Unmarshal([]byte(designValue1.ValueString()), &designInst1) - design1[designKey1] = designInst1 - } - isDeleted := new(bool) - if !r.IsDeleted.IsUnknown() && !r.IsDeleted.IsNull() { - *isDeleted = r.IsDeleted.ValueBool() - } else { - isDeleted = nil - } - isEntryRoute := new(bool) - if !r.IsEntryRoute.IsUnknown() && !r.IsEntryRoute.IsNull() { - *isEntryRoute = r.IsEntryRoute.ValueBool() - } else { - isEntryRoute = nil - } - isPublic := new(bool) - if !r.IsPublic.IsUnknown() && !r.IsPublic.IsNull() { - *isPublic = r.IsPublic.ValueBool() - } else { - isPublic = nil - } - isSystem := new(bool) - if !r.IsSystem.IsUnknown() && !r.IsSystem.IsNull() { - *isSystem = r.IsSystem.ValueBool() - } else { - isSystem = nil - } - var order1 float64 - order1 = r.Order.ValueFloat64() - - parentId1 := new(string) - if !r.ParentID.IsUnknown() && !r.ParentID.IsNull() { - *parentId1 = r.ParentID.ValueString() - } else { - parentId1 = nil - } - path := new(string) - if !r.Path.IsUnknown() && !r.Path.IsNull() { - *path = r.Path.ValueString() - } else { - path = nil - } - schema := make([]shared.PageRequestSchema, 0, len(r.Schema)) - for _, schemaItem := range r.Schema { - schema = append(schema, shared.PageRequestSchema(schemaItem.ValueString())) - } - var slug string - slug = r.Slug.ValueString() - - visibility1 := make(map[string]interface{}) - for visibilityKey1, visibilityValue1 := range r.Visibility { - var visibilityInst1 interface{} - _ = json.Unmarshal([]byte(visibilityValue1.ValueString()), &visibilityInst1) - visibility1[visibilityKey1] = visibilityInst1 - } - out := shared.PageRequest{ - AdditionalProperties: additionalProperties, - Blocks: blocks, - Content: content1, - Design: design1, - IsDeleted: isDeleted, - IsEntryRoute: isEntryRoute, - IsPublic: isPublic, - IsSystem: isSystem, - Order: order1, - ParentID: parentId1, - Path: path, - Schema: schema, - Slug: slug, - Visibility: visibility1, - } - - return &out, diags -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 5a1c02d..92f0313 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -27,9 +27,8 @@ type EpilotPortalProvider struct { // EpilotPortalProviderModel describes the provider data model. type EpilotPortalProviderModel struct { - EitherAuth types.String `tfsdk:"either_auth"` EpilotAuth types.String `tfsdk:"epilot_auth"` - PortalAuth types.String `tfsdk:"portal_auth"` + EpilotOrg types.String `tfsdk:"epilot_org"` ServerURL types.String `tfsdk:"server_url"` } @@ -41,27 +40,22 @@ func (p *EpilotPortalProvider) Metadata(ctx context.Context, req provider.Metada func (p *EpilotPortalProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ - "either_auth": schema.StringAttribute{ - MarkdownDescription: `Portal or Epilot Bearer Token.`, - Optional: true, - Sensitive: true, - }, "epilot_auth": schema.StringAttribute{ - MarkdownDescription: `Epilot Bearer Token.`, + MarkdownDescription: `Authorization header with epilot OAuth2 bearer token.`, Optional: true, Sensitive: true, }, - "portal_auth": schema.StringAttribute{ - MarkdownDescription: `Portal Cognito Token.`, + "epilot_org": schema.StringAttribute{ + MarkdownDescription: `Overrides the target organization to allow shared tenantaccess.`, Optional: true, Sensitive: true, }, "server_url": schema.StringAttribute{ - Description: `Server URL (defaults to https://customer-portal-api.sls.epilot.io/)`, + Description: `Server URL (defaults to https://permissions.sls.epilot.io)`, Optional: true, }, }, - MarkdownDescription: `Portal API: Backend for epilot portals - End Customer Portal & Installer Portal`, + MarkdownDescription: `Permissions API: Flexible Role-based Access Control for epilot`, } } @@ -77,21 +71,17 @@ func (p *EpilotPortalProvider) Configure(ctx context.Context, req provider.Confi serverUrl := data.ServerURL.ValueString() if serverUrl == "" { - serverUrl = "https://customer-portal-api.sls.epilot.io/" + serverUrl = "https://permissions.sls.epilot.io" } security := shared.Security{} - if !data.EitherAuth.IsUnknown() { - security.EitherAuth = data.EitherAuth.ValueStringPointer() - } - if !data.EpilotAuth.IsUnknown() { security.EpilotAuth = data.EpilotAuth.ValueStringPointer() } - if !data.PortalAuth.IsUnknown() { - security.PortalAuth = data.PortalAuth.ValueStringPointer() + if !data.EpilotOrg.IsUnknown() { + security.EpilotOrg = data.EpilotOrg.ValueStringPointer() } providerHTTPTransportOpts := ProviderHTTPTransportOpts{ @@ -115,17 +105,11 @@ func (p *EpilotPortalProvider) Configure(ctx context.Context, req provider.Confi } func (p *EpilotPortalProvider) Resources(ctx context.Context) []func() resource.Resource { - return []func() resource.Resource{ - NewPortalConfigResource, - NewPortalPageResource, - } + return []func() resource.Resource{} } func (p *EpilotPortalProvider) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{ - NewPortalConfigDataSource, - NewPortalPageDataSource, - } + return []func() datasource.DataSource{} } func (p *EpilotPortalProvider) EphemeralResources(ctx context.Context) []func() ephemeral.EphemeralResource { diff --git a/internal/provider/types/admin_user.go b/internal/provider/types/admin_user.go deleted file mode 100644 index af03dd3..0000000 --- a/internal/provider/types/admin_user.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type AdminUser struct { - AdditionalProperties jsontypes.Normalized `tfsdk:"additional_properties"` - DisplayName types.String `tfsdk:"display_name"` - Email types.String `tfsdk:"email"` - ImageURI *ImageURI `tfsdk:"image_uri"` - OrgID types.String `tfsdk:"org_id"` - Phone types.String `tfsdk:"phone"` - Type types.String `tfsdk:"type"` - UserID types.String `tfsdk:"user_id"` -} diff --git a/internal/provider/types/allowed_file_extensions.go b/internal/provider/types/allowed_file_extensions.go deleted file mode 100644 index 4a558f2..0000000 --- a/internal/provider/types/allowed_file_extensions.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type AllowedFileExtensions struct { - Archive []types.String `tfsdk:"archive"` - AudioVideo []types.String `tfsdk:"audio_video"` - Cad []types.String `tfsdk:"cad"` - Calendar []types.String `tfsdk:"calendar"` - Document []types.String `tfsdk:"document"` - Email []types.String `tfsdk:"email"` - Image []types.String `tfsdk:"image"` - Other []types.String `tfsdk:"other"` - Presentation []types.String `tfsdk:"presentation"` - Spreadsheet []types.String `tfsdk:"spreadsheet"` -} diff --git a/internal/provider/types/block.go b/internal/provider/types/block.go deleted file mode 100644 index 824b2d5..0000000 --- a/internal/provider/types/block.go +++ /dev/null @@ -1,17 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type Block struct { - AdditionalProperties jsontypes.Normalized `tfsdk:"additional_properties"` - ID types.String `tfsdk:"id"` - Order types.Float64 `tfsdk:"order"` - ParentID types.String `tfsdk:"parent_id"` - Props *BlockProps `tfsdk:"props"` - Type types.String `tfsdk:"type"` -} diff --git a/internal/provider/types/block_props.go b/internal/provider/types/block_props.go deleted file mode 100644 index 6918d04..0000000 --- a/internal/provider/types/block_props.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes" -) - -type BlockProps struct { - AdditionalProperties jsontypes.Normalized `tfsdk:"additional_properties"` - Content map[string]jsontypes.Normalized `tfsdk:"content"` - Design map[string]jsontypes.Normalized `tfsdk:"design"` - Visibility map[string]jsontypes.Normalized `tfsdk:"visibility"` -} diff --git a/internal/provider/types/email_templates.go b/internal/provider/types/email_templates.go deleted file mode 100644 index b8eb765..0000000 --- a/internal/provider/types/email_templates.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type EmailTemplates struct { - AdvancedAuth types.String `tfsdk:"advanced_auth"` - AdvancedMFA types.String `tfsdk:"advanced_mfa"` - ConfirmAccount types.String `tfsdk:"confirm_account"` - ConfirmEmailUpdate types.String `tfsdk:"confirm_email_update"` - ForgotPassword types.String `tfsdk:"forgot_password"` - Invitation types.String `tfsdk:"invitation"` - JourneyLoginOTP types.String `tfsdk:"journey_login_otp"` - JourneySignInOneTimePassword types.String `tfsdk:"journey_sign_in_one_time_password"` - JourneySignUp types.String `tfsdk:"journey_sign_up"` - OnDocUpload types.String `tfsdk:"on_doc_upload"` - OnMapAPendingUser types.String `tfsdk:"on_map_a_pending_user"` - OnNewQuote types.String `tfsdk:"on_new_quote"` - OnWorkflowStepAssigned types.String `tfsdk:"on_workflow_step_assigned"` - VerifyCodeToSetPassword types.String `tfsdk:"verify_code_to_set_password"` -} diff --git a/internal/provider/types/entity_actions.go b/internal/provider/types/entity_actions.go deleted file mode 100644 index d315ae2..0000000 --- a/internal/provider/types/entity_actions.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type EntityActions struct { - ActionLabel *UpsertPortalConfigV3ActionLabel `tfsdk:"action_label"` - JourneyID types.String `tfsdk:"journey_id"` - Slug types.String `tfsdk:"slug"` -} diff --git a/internal/provider/types/extension_config.go b/internal/provider/types/extension_config.go deleted file mode 100644 index 9b8a70b..0000000 --- a/internal/provider/types/extension_config.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ExtensionConfig struct { - ID types.String `tfsdk:"id"` - Options map[string]types.String `tfsdk:"options"` - Status types.String `tfsdk:"status"` -} diff --git a/internal/provider/types/extension_hook_config.go b/internal/provider/types/extension_hook_config.go deleted file mode 100644 index 7c5d4b8..0000000 --- a/internal/provider/types/extension_hook_config.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ExtensionHookConfig struct { - AppID types.String `tfsdk:"app_id"` - HookID types.String `tfsdk:"hook_id"` -} diff --git a/internal/provider/types/image_uri.go b/internal/provider/types/image_uri.go deleted file mode 100644 index 4d4d667..0000000 --- a/internal/provider/types/image_uri.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type ImageURI struct { - Key types.String `tfsdk:"key"` - Original types.String `tfsdk:"original"` - Thumbnail32 types.String `tfsdk:"thumbnail_32"` - Thumbnail64 types.String `tfsdk:"thumbnail_64"` -} diff --git a/internal/provider/types/portal_config_v3_org_settings.go b/internal/provider/types/portal_config_v3_org_settings.go deleted file mode 100644 index 002ec39..0000000 --- a/internal/provider/types/portal_config_v3_org_settings.go +++ /dev/null @@ -1,8 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type PortalConfigV3OrgSettings struct { - Canary *UpsertPortalConfigV3AdvancedMfa `tfsdk:"canary"` - Notracking *UpsertPortalConfigV3AdvancedMfa `tfsdk:"notracking"` -} diff --git a/internal/provider/types/portal_config_v3_triggered_journeys.go b/internal/provider/types/portal_config_v3_triggered_journeys.go deleted file mode 100644 index 2e1cb8b..0000000 --- a/internal/provider/types/portal_config_v3_triggered_journeys.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type PortalConfigV3TriggeredJourneys struct { - JourneyID types.String `tfsdk:"journey_id"` - TriggerName types.String `tfsdk:"trigger_name"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_action_label.go b/internal/provider/types/upsert_portal_config_v3_action_label.go deleted file mode 100644 index 0b05040..0000000 --- a/internal/provider/types/upsert_portal_config_v3_action_label.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3ActionLabel struct { - De types.String `tfsdk:"de"` - En types.String `tfsdk:"en"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_advanced_mfa.go b/internal/provider/types/upsert_portal_config_v3_advanced_mfa.go deleted file mode 100644 index 6dd7194..0000000 --- a/internal/provider/types/upsert_portal_config_v3_advanced_mfa.go +++ /dev/null @@ -1,11 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3AdvancedMfa struct { - Enabled types.Bool `tfsdk:"enabled"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_auth_settings.go b/internal/provider/types/upsert_portal_config_v3_auth_settings.go deleted file mode 100644 index 45f191d..0000000 --- a/internal/provider/types/upsert_portal_config_v3_auth_settings.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3AuthSettings struct { - AutoRedirectToSso types.Bool `tfsdk:"auto_redirect_to_sso"` - EntryPoint types.String `tfsdk:"entry_point"` - PasswordlessLogin *UpsertPortalConfigV3AdvancedMfa `tfsdk:"passwordless_login"` - PreferredSsoProviders []types.String `tfsdk:"preferred_sso_providers"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_cognito_details.go b/internal/provider/types/upsert_portal_config_v3_cognito_details.go deleted file mode 100644 index 7cc4797..0000000 --- a/internal/provider/types/upsert_portal_config_v3_cognito_details.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3CognitoDetails struct { - CognitoUserPoolArn types.String `tfsdk:"cognito_user_pool_arn"` - CognitoUserPoolClientID types.String `tfsdk:"cognito_user_pool_client_id"` - CognitoUserPoolID types.String `tfsdk:"cognito_user_pool_id"` - PasswordPolicy *UpsertPortalConfigV3PasswordPolicy `tfsdk:"password_policy"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_contract_selector_config.go b/internal/provider/types/upsert_portal_config_v3_contract_selector_config.go deleted file mode 100644 index 826702d..0000000 --- a/internal/provider/types/upsert_portal_config_v3_contract_selector_config.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3ContractSelectorConfig struct { - ShowInactive types.Bool `tfsdk:"show_inactive"` - TitlePath types.String `tfsdk:"title_path"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_default_user_to_notify.go b/internal/provider/types/upsert_portal_config_v3_default_user_to_notify.go deleted file mode 100644 index 12439d3..0000000 --- a/internal/provider/types/upsert_portal_config_v3_default_user_to_notify.go +++ /dev/null @@ -1,7 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type UpsertPortalConfigV3DefaultUserToNotify struct { - OnPendingUser []AdminUser `tfsdk:"on_pending_user"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_entity_identifiers.go b/internal/provider/types/upsert_portal_config_v3_entity_identifiers.go deleted file mode 100644 index 35521ee..0000000 --- a/internal/provider/types/upsert_portal_config_v3_entity_identifiers.go +++ /dev/null @@ -1,7 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -type UpsertPortalConfigV3EntityIdentifiers struct { - Type *UpsertPortalConfigV3Type `tfsdk:"type"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_feature_settings.go b/internal/provider/types/upsert_portal_config_v3_feature_settings.go deleted file mode 100644 index 12a98ed..0000000 --- a/internal/provider/types/upsert_portal_config_v3_feature_settings.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3FeatureSettings struct { - Billing types.Bool `tfsdk:"billing"` - ChangeDueDate types.Bool `tfsdk:"change_due_date"` - NewDesign types.Bool `tfsdk:"new_design"` - StartPage types.Bool `tfsdk:"start_page"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_images.go b/internal/provider/types/upsert_portal_config_v3_images.go deleted file mode 100644 index df1322a..0000000 --- a/internal/provider/types/upsert_portal_config_v3_images.go +++ /dev/null @@ -1,13 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3Images struct { - OrderLeftTeaser types.String `tfsdk:"order_left_teaser"` - OrderRightTeaser types.String `tfsdk:"order_right_teaser"` - WelcomeBanner types.String `tfsdk:"welcome_banner"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_password_policy.go b/internal/provider/types/upsert_portal_config_v3_password_policy.go deleted file mode 100644 index 4a8bb6a..0000000 --- a/internal/provider/types/upsert_portal_config_v3_password_policy.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3PasswordPolicy struct { - MinimumLength types.Int64 `tfsdk:"minimum_length"` - RequireLowercase types.Bool `tfsdk:"require_lowercase"` - RequireNumbers types.Bool `tfsdk:"require_numbers"` - RequireSymbols types.Bool `tfsdk:"require_symbols"` - RequireUppercase types.Bool `tfsdk:"require_uppercase"` -} diff --git a/internal/provider/types/upsert_portal_config_v3_type.go b/internal/provider/types/upsert_portal_config_v3_type.go deleted file mode 100644 index 0cea9ce..0000000 --- a/internal/provider/types/upsert_portal_config_v3_type.go +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" -) - -type UpsertPortalConfigV3Type struct { - Attributes []types.String `tfsdk:"attributes"` - IsEnabled types.Bool `tfsdk:"is_enabled"` -} diff --git a/internal/provider/utils.go b/internal/provider/utils.go index a2a4226..a11ecc7 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -28,6 +28,9 @@ func debugResponse(response *http.Response) string { if v := response.Request.Header.Get("Authorization"); v != "" { response.Request.Header.Set("Authorization", "(sensitive)") } + if v := response.Request.Header.Get("x-epilot-org-id"); v != "" { + response.Request.Header.Set("x-epilot-org-id", "(sensitive)") + } dumpReq, err := httputil.DumpRequest(response.Request, true) if err != nil { dumpReq, err = httputil.DumpRequest(response.Request, false) @@ -243,6 +246,9 @@ func fieldHeadersFromRequestReader(reader *textproto.Reader, fields map[string]i if _, ok := fields["Authorization"]; ok { fields["Authorization"] = "(sensitive)" } + if _, ok := fields["x-epilot-org-id"]; ok { + fields["x-epilot-org-id"] = "(sensitive)" + } return nil } diff --git a/internal/sdk/.gitignore b/internal/sdk/.gitignore index a1e4382..e9661d1 100644 --- a/internal/sdk/.gitignore +++ b/internal/sdk/.gitignore @@ -1,3 +1,5 @@ +.env +.env.local # .gitignore .DS_Store **/.speakeasy/temp/ diff --git a/internal/sdk/activity.go b/internal/sdk/activity.go deleted file mode 100644 index 9af42a1..0000000 --- a/internal/sdk/activity.go +++ /dev/null @@ -1,233 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" -) - -type Activity struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newActivity(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Activity { - return &Activity{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// GetEntityActivityFeed - getEntityActivityFeed -// Get activity feed for an entity -func (s *Activity) GetEntityActivityFeed(ctx context.Context, request operations.GetEntityActivityFeedRequest, opts ...operations.Option) (*operations.GetEntityActivityFeedResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/entity/{slug}/{id}/activity", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getEntityActivityFeed", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetEntityActivityFeedResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetEntityActivityFeedResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/assignments.go b/internal/sdk/assignments.go new file mode 100644 index 0000000..a876b57 --- /dev/null +++ b/internal/sdk/assignments.go @@ -0,0 +1,1037 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdk + +import ( + "bytes" + "context" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" + "net/http" + "net/url" +) + +// Assignments - Assign roles to users +type Assignments struct { + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks +} + +func newAssignments(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Assignments { + return &Assignments{ + rootSDK: rootSDK, + sdkConfiguration: sdkConfig, + hooks: hooks, + } +} + +// AddAssignment - addAssignment +// Assign a user to a role. +// +// Use the `x-epilot-org-id` header to assign share roles to users in other orgs +func (s *Assignments) AddAssignment(ctx context.Context, request operations.AddAssignmentRequest, opts ...operations.Option) (*operations.AddAssignmentResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/assignments/{userId}/{roleId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "addAssignment", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AddAssignmentResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Assignment + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Assignment = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// AssignRoles - assignRoles +// Assign / unassign roles to users. +func (s *Assignments) AssignRoles(ctx context.Context, request operations.AssignRolesRequest, opts ...operations.Option) (*operations.AssignRolesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/assignments/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "assignRoles", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + 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) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AssignRolesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out []string + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Assignments = out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetAssignedRolesForUser - getAssignedRolesForUser +// Get list of assigned roles by user id +func (s *Assignments) GetAssignedRolesForUser(ctx context.Context, request operations.GetAssignedRolesForUserRequest, opts ...operations.Option) (*operations.GetAssignedRolesForUserResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/assignments/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getAssignedRolesForUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetAssignedRolesForUserResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out []string + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Assignments = out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ListAllAssignments - listAllAssignments +// Returns list of all assignments in organization +func (s *Assignments) ListAllAssignments(ctx context.Context, opts ...operations.Option) (*operations.ListAllAssignmentsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/assignments") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listAllAssignments", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListAllAssignmentsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out operations.ListAllAssignmentsResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// RemoveAssignment - removeAssignment +// Remove role assignment from user +func (s *Assignments) RemoveAssignment(ctx context.Context, request operations.RemoveAssignmentRequest, opts ...operations.Option) (*operations.RemoveAssignmentResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/assignments/{userId}/{roleId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "removeAssignment", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RemoveAssignmentResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Assignment + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Assignment = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/internal/sdk/balance.go b/internal/sdk/balance.go deleted file mode 100644 index 793ed23..0000000 --- a/internal/sdk/balance.go +++ /dev/null @@ -1,231 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -type Balance struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newBalance(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Balance { - return &Balance{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// GetCustomerBalance - getCustomerBalance -// Get total balance across all contracts and orders of a customer entity. -func (s *Balance) GetCustomerBalance(ctx context.Context, opts ...operations.Option) (*operations.GetCustomerBalanceResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/billing/customers/balance") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getCustomerBalance", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetCustomerBalanceResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Balance - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Balance = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/ecp.go b/internal/sdk/ecp.go deleted file mode 100644 index c5d937d..0000000 --- a/internal/sdk/ecp.go +++ /dev/null @@ -1,12983 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -// Ecp - APIs defined for a portal user -type Ecp struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newEcp(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Ecp { - return &Ecp{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// AddContractByIdentifiers - addContractByIdentifiers -// Self-assign contract(s) by pre-configured identifiers. -func (s *Ecp) AddContractByIdentifiers(ctx context.Context, request map[string]map[string]string, opts ...operations.Option) (*operations.AddContractByIdentifiersResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/contract/by-identifiers") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "addContractByIdentifiers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.AddContractByIdentifiersResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.AddContractByIdentifiersResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 409: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.AddContractByIdentifiersECPResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object1 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// CreateCustomEntityActivity - createCustomEntityActivity -// Create a custom activity that can be displayed in activity feed of an entity. -func (s *Ecp) CreateCustomEntityActivity(ctx context.Context, request operations.CreateCustomEntityActivityRequest, opts ...operations.Option) (*operations.CreateCustomEntityActivityResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/entity/activity") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "createCustomEntityActivity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CreateCustomEntityActivityResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ActivityItem - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ActivityItem = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeleteEntityFile - deleteEntityFile -// Delete files from an entity -func (s *Ecp) DeleteEntityFile(ctx context.Context, request shared.DeleteEntityFile, opts ...operations.Option) (*operations.DeleteEntityFileResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/entity/file") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deleteEntityFile", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeleteEntityFileResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 202: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.DeleteEntityFileResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeletePortalUser - deletePortalUser -// Delete the portal user -func (s *Ecp) DeletePortalUser(ctx context.Context, opts ...operations.Option) (*operations.DeletePortalUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deletePortalUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeletePortalUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.DeletePortalUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllContracts - getAllContracts -// Get all contracts for a portal user -func (s *Ecp) GetAllContracts(ctx context.Context, request operations.GetAllContractsRequest, opts ...operations.Option) (*operations.GetAllContractsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/contract") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllContracts", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllContractsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllContractsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllFiles - getAllFiles -// Fetch all documents under the related entities of a contact -func (s *Ecp) GetAllFiles(ctx context.Context, request operations.GetAllFilesRequest, opts ...operations.Option) (*operations.GetAllFilesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user/files") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllFiles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllFilesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllFilesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllOpportunities - getAllOpportunities -// Get all opportunities of a portal user -func (s *Ecp) GetAllOpportunities(ctx context.Context, request operations.GetAllOpportunitiesRequest, opts ...operations.Option) (*operations.GetAllOpportunitiesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/opportunity") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllOpportunities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllOpportunitiesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllOpportunitiesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllOrders - getAllOrders -// Get all orders for the portal user -func (s *Ecp) GetAllOrders(ctx context.Context, request operations.GetAllOrdersRequest, opts ...operations.Option) (*operations.GetAllOrdersResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/order") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllOrders", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllOrdersResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllOrdersResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllRequests - getAllRequests -// Get all opportunities & orders of a portal user -func (s *Ecp) GetAllRequests(ctx context.Context, request operations.GetAllRequestsRequest, opts ...operations.Option) (*operations.GetAllRequestsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/request") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllRequests", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllRequestsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllRequestsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAutomationContext - getAutomationContext -// Retrieves the automation context. -func (s *Ecp) GetAutomationContext(ctx context.Context, request operations.GetAutomationContextRequest, opts ...operations.Option) (*operations.GetAutomationContextResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/automation-context") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAutomationContext", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAutomationContextResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out map[string]map[string]any - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetBillingEvents - getBillingEvents -// Fetch billing events for a portal user -func (s *Ecp) GetBillingEvents(ctx context.Context, request operations.GetBillingEventsRequest, opts ...operations.Option) (*operations.GetBillingEventsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/billing/events") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getBillingEvents", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetBillingEventsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetBillingEventsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetConsumption - Get Consumption -// Get energy consumption data between a given time period. -func (s *Ecp) GetConsumption(ctx context.Context, request operations.GetConsumptionRequest, opts ...operations.Option) (*operations.GetConsumptionResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/consumption") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getConsumption", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetConsumptionResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetConsumptionResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetContact - getContact -// Retrieves the contact of the logged in user. -func (s *Ecp) GetContact(ctx context.Context, opts ...operations.Option) (*operations.GetContactResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/contact") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getContact", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetContactResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetContactResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetContract - getContract -// Get a contract by id -func (s *Ecp) GetContract(ctx context.Context, request operations.GetContractRequest, opts ...operations.Option) (*operations.GetContractResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/contract/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getContract", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetContractResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetContractResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetCosts - Get Costs -// Get energy cost data between a given time period. -func (s *Ecp) GetCosts(ctx context.Context, request operations.GetCostsRequest, opts ...operations.Option) (*operations.GetCostsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/costs") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getCosts", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetCostsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetCostsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetExternalLinks - getExternalLinks -// Retrieves the portal configuration external links. -func (s *Ecp) GetExternalLinks(ctx context.Context, request operations.GetExternalLinksRequest, opts ...operations.Option) (*operations.GetExternalLinksResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/external-links") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getExternalLinks", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetExternalLinksResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.ExternalLink - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetFileByID - getFileById -// Fetch a document with ID -func (s *Ecp) GetFileByID(ctx context.Context, request operations.GetFileByIDRequest, opts ...operations.Option) (*operations.GetFileByIDResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/user/file/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getFileById", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetFileByIDResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetFileByIDResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetFilesCountByEntity - getFileCountByEntity -// Fetch file counts for all ECP user related entities -func (s *Ecp) GetFilesCountByEntity(ctx context.Context, opts ...operations.Option) (*operations.GetFilesCountByEntityResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user/files/count-by-entity") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getFilesCountByEntity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetFilesCountByEntityResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.EntityFileCount - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetOpportunity - getOpportunity -// Get an opportunity by id -func (s *Ecp) GetOpportunity(ctx context.Context, request operations.GetOpportunityRequest, opts ...operations.Option) (*operations.GetOpportunityResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/opportunities/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getOpportunity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetOpportunityResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetOpportunityResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetOrder - getOrder -// Get an order by id -func (s *Ecp) GetOrder(ctx context.Context, request operations.GetOrderRequest, opts ...operations.Option) (*operations.GetOrderResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/order/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getOrder", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetOrderResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetOrderResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetOrganizationSettings - getOrganizationSettings -// Retrieves the organization settings. This endpoint is deprecated, use org_settings from the portal config or getOrganizationSettingsByDomain instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Ecp) GetOrganizationSettings(ctx context.Context, opts ...operations.Option) (*operations.GetOrganizationSettingsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/org/settings") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getOrganizationSettings", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetOrganizationSettingsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetOrganizationSettingsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalConfig - getPortalConfig -// Retrieves the portal configuration. -func (s *Ecp) GetPortalConfig(ctx context.Context, request operations.GetPortalConfigRequest, opts ...operations.Option) (*operations.GetPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfig - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfig = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalConfigV3 - getPortalConfigV3 -// Retrieves a specific portal configuration by ID. -func (s *Ecp) GetPortalConfigV3(ctx context.Context, request operations.GetPortalConfigV3Request, opts ...operations.Option) (*operations.GetPortalConfigV3Response, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v3/portal/config/{portal_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalConfigV3", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalConfigV3Response{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfigV3 - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfigV3 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPage - getPortalPage -// Fetch a portal page by id -func (s *Ecp) GetPortalPage(ctx context.Context, request operations.GetPortalPageRequest, opts ...operations.Option) (*operations.GetPortalPageResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Page = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPageBlock - getPortalPageBlock -// Fetch a portal page block by id -func (s *Ecp) GetPortalPageBlock(ctx context.Context, request operations.GetPortalPageBlockRequest, opts ...operations.Option) (*operations.GetPortalPageBlockResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks/{block_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPageBlock", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageBlockResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Block = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPageBlocks - getPortalPageBlocks -// Fetch all portal page blocks -func (s *Ecp) GetPortalPageBlocks(ctx context.Context, request operations.GetPortalPageBlocksRequest, opts ...operations.Option) (*operations.GetPortalPageBlocksResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPageBlocks", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageBlocksResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPages - getPortalPages -// Fetch all portal pages -func (s *Ecp) GetPortalPages(ctx context.Context, request operations.GetPortalPagesRequest, opts ...operations.Option) (*operations.GetPortalPagesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/pages") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPages", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPagesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalUser - getPortalUser -// Get the portal user details -func (s *Ecp) GetPortalUser(ctx context.Context, opts ...operations.Option) (*operations.GetPortalUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetPortalUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalWidgets - getPortalWidgets -// Retrieves the widgets of a portal -func (s *Ecp) GetPortalWidgets(ctx context.Context, request operations.GetPortalWidgetsRequest, opts ...operations.Option) (*operations.GetPortalWidgetsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/widgets") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalWidgets", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalWidgetsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.UpsertPortalWidget - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpsertPortalWidget = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPrices - Get Prices -// Get energy prices data between a given time period. -func (s *Ecp) GetPrices(ctx context.Context, request operations.GetPricesRequest, opts ...operations.Option) (*operations.GetPricesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/prices") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPrices", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPricesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetPricesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetResolvedExternalLink - getResolvedExternalLink -// Retrieves a resolved portal external link. Use /v2/portal/resolve:seamless-link/{id} instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Ecp) GetResolvedExternalLink(ctx context.Context, request operations.GetResolvedExternalLinkRequest, opts ...operations.Option) (*operations.GetResolvedExternalLinkResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/resolve:external-link/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getResolvedExternalLink", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetResolvedExternalLinkResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ExternalLink - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ExternalLink = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetResolvedSeamlessLink - getResolvedSeamlessLink -// Retrieves a resolved seamless portal link. -func (s *Ecp) GetResolvedSeamlessLink(ctx context.Context, request operations.GetResolvedSeamlessLinkRequest, opts ...operations.Option) (*operations.GetResolvedSeamlessLinkResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/resolve:seamless-link") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getResolvedSeamlessLink", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetResolvedSeamlessLinkResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetResolvedSeamlessLinkResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetSchemas - getSchemas -// Retrieves the schemas. Only schemas usable in the private part of the portal are returned. -func (s *Ecp) GetSchemas(ctx context.Context, opts ...operations.Option) (*operations.GetSchemasResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/schemas") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getSchemas", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetSchemasResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetSchemasResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetSearchResultsForOpportunities - getSearchResultsForOpportunities -// Get all opportunity with the given serached attributes -func (s *Ecp) GetSearchResultsForOpportunities(ctx context.Context, request operations.GetSearchResultsForOpportunitiesRequest, opts ...operations.Option) (*operations.GetSearchResultsForOpportunitiesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/opportunities/search") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getSearchResultsForOpportunities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetSearchResultsForOpportunitiesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetSearchResultsForOpportunitiesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetSearchableAttributesForOpportunities - getSearchableAttributesForOpportunities -// Get all opportunity searchable attributes for a portal user -func (s *Ecp) GetSearchableAttributesForOpportunities(ctx context.Context, request operations.GetSearchableAttributesForOpportunitiesRequest, opts ...operations.Option) (*operations.GetSearchableAttributesForOpportunitiesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/opportunities/searchable-attributes") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getSearchableAttributesForOpportunities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetSearchableAttributesForOpportunitiesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetSearchableAttributesForOpportunitiesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// PostOrderAcceptance - postOrderAcceptance -// Accept/decline an offer by id -func (s *Ecp) PostOrderAcceptance(ctx context.Context, request operations.PostOrderAcceptanceRequest, opts ...operations.Option) (*operations.PostOrderAcceptanceResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/order/{id}/acceptance", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "postOrderAcceptance", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "AcceptanceDecision", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.PostOrderAcceptanceResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.PostOrderAcceptanceResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 409: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// RevokeToken - revokeToken -// Revokes all of the access tokens for the given Refresh Token. -func (s *Ecp) RevokeToken(ctx context.Context, request operations.RevokeTokenRequestBody, opts ...operations.Option) (*operations.RevokeTokenResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/token/revoke") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "revokeToken", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.RevokeTokenResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.RevokeTokenResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SaveEntityFile - saveEntityFile -// Add files to an entity -func (s *Ecp) SaveEntityFile(ctx context.Context, request shared.SaveEntityFile, opts ...operations.Option) (*operations.SaveEntityFileResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/entity/file") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "saveEntityFile", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SaveEntityFileResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SaveEntityFileResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SearchPaymentRelationsInEntities - searchPaymentRelationsInEntities -// Search for entities that have the payment relation with the given payment id -func (s *Ecp) SearchPaymentRelationsInEntities(ctx context.Context, request operations.SearchPaymentRelationsInEntitiesRequest, opts ...operations.Option) (*operations.SearchPaymentRelationsInEntitiesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/entities-by-payment/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "searchPaymentRelationsInEntities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SearchPaymentRelationsInEntitiesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SearchPaymentRelationsInEntitiesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SearchPortalUserEntities - searchPortalUserEntities -// Search all entities of a portal user -func (s *Ecp) SearchPortalUserEntities(ctx context.Context, request *shared.EntitySearchParams, opts ...operations.Option) (*operations.SearchPortalUserEntitiesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/entity:search") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "searchPortalUserEntities", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SearchPortalUserEntitiesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SearchPortalUserEntitiesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.OneOf = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// TrackFileDownloaded - trackFileDownloaded -// Track that user has downloaded a file -func (s *Ecp) TrackFileDownloaded(ctx context.Context, request operations.TrackFileDownloadedRequest, opts ...operations.Option) (*operations.TrackFileDownloadedResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/user/file/{id}/downloaded", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "trackFileDownloaded", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.TrackFileDownloadedResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.TrackFileDownloadedResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// TriggerEntityAccessEvent - triggerEntityAccessEvent -// Trigger entity access event for a portal user -func (s *Ecp) TriggerEntityAccessEvent(ctx context.Context, request operations.TriggerEntityAccessEventRequest, opts ...operations.Option) (*operations.TriggerEntityAccessEventResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/entity/{schema}/access", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "triggerEntityAccessEvent", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.TriggerEntityAccessEventResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.TriggerEntityAccessEventResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateCampaignPortalBlockStatus - Update Campaign Portal Block Status -// Updates the status of a campaign portal block for multiple recipients. -func (s *Ecp) UpdateCampaignPortalBlockStatus(ctx context.Context, request operations.UpdateCampaignPortalBlockStatusRequest, opts ...operations.Option) (*operations.UpdateCampaignPortalBlockStatusResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/campaign/{campaign_id}/entity:status", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateCampaignPortalBlockStatus", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateCampaignPortalBlockStatusResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateCampaignPortalBlockStatusResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateContact - updateContact -// Updates the contact details. -func (s *Ecp) UpdateContact(ctx context.Context, request map[string]any, opts ...operations.Option) (*operations.UpdateContactResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/contact") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateContact", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateContactResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateContactResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateContactECPResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.OneOf = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateContract - updateContract -// Update a contract by id -func (s *Ecp) UpdateContract(ctx context.Context, request operations.UpdateContractRequest, opts ...operations.Option) (*operations.UpdateContractResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/contract/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateContract", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateContractResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateContractResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateContractECPResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.OneOf = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateOpportunity - updateOpportunity -// Update an opportunity by id -func (s *Ecp) UpdateOpportunity(ctx context.Context, request operations.UpdateOpportunityRequest, opts ...operations.Option) (*operations.UpdateOpportunityResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/opportunities/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateOpportunity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateOpportunityResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateOpportunityResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateOrder - updateOrder -// Update an order by id -func (s *Ecp) UpdateOrder(ctx context.Context, request operations.UpdateOrderRequest, opts ...operations.Option) (*operations.UpdateOrderResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/order/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateOrder", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateOrderResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdateOrderResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdatePortalUser - updatePortalUser -// Update the portal user details -func (s *Ecp) UpdatePortalUser(ctx context.Context, request map[string]any, opts ...operations.Option) (*operations.UpdatePortalUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updatePortalUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdatePortalUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdatePortalUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdatePortalUserEmail - updatePortalUserEmail -// Update portal user email -func (s *Ecp) UpdatePortalUserEmail(ctx context.Context, request operations.UpdatePortalUserEmailRequestBody, opts ...operations.Option) (*operations.UpdatePortalUserEmailResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user/update/email") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updatePortalUserEmail", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdatePortalUserEmailResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpdatePortalUserEmailResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateWorkflowStepAsDone - updateWorkflowStepAsDone -// Update a workflow step as done -func (s *Ecp) UpdateWorkflowStepAsDone(ctx context.Context, request operations.UpdateWorkflowStepAsDoneRequest, opts ...operations.Option) (*operations.UpdateWorkflowStepAsDoneResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/workflow/{workflow_id}/{step_id}:markDone", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updateWorkflowStepAsDone", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdateWorkflowStepAsDoneResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out map[string]any - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.WorkflowStep = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UploadMeterReadingPhoto - Upload Meter Reading Photo -// Uploads a Meter Reading photo and - if enabled - gives back data extracted from the photo. -func (s *Ecp) UploadMeterReadingPhoto(ctx context.Context, request shared.MeterReadingPhoto, opts ...operations.Option) (*operations.UploadMeterReadingPhotoResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/metering/reading/photo") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "uploadMeterReadingPhoto", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UploadMeterReadingPhotoResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UploadMeterReadingPhotoResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ValidateCadenceEntityEditRules - validateCadenceEntityEditRules -// Validate if cadence rule is valid for an entity -func (s *Ecp) ValidateCadenceEntityEditRules(ctx context.Context, request operations.ValidateCadenceEntityEditRulesRequest, opts ...operations.Option) (*operations.ValidateCadenceEntityEditRulesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/{slug}/{id}:validateRule", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "validateCadenceEntityEditRules", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ValidateCadenceEntityEditRulesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ValidateCadenceEntityEditRulesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ValidateToken - validateToken -// Validates Portal Token is valid. Pass the token via Authorization Header. -func (s *Ecp) ValidateToken(ctx context.Context, opts ...operations.Option) (*operations.ValidateTokenResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/token/validate") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "validateToken", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ValidateTokenResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/ecpadmin.go b/internal/sdk/ecpadmin.go deleted file mode 100644 index 8a00ee4..0000000 --- a/internal/sdk/ecpadmin.go +++ /dev/null @@ -1,10493 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -// ECPAdmin - APIs defined for a ECP Admin -type ECPAdmin struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newECPAdmin(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *ECPAdmin { - return &ECPAdmin{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// CanTriggerPortalFlow - canTriggerPortalFlow -// Returns whether the user can trigger a portal flow -func (s *ECPAdmin) CanTriggerPortalFlow(ctx context.Context, request operations.CanTriggerPortalFlowRequest, opts ...operations.Option) (*operations.CanTriggerPortalFlowResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/can-trigger-portal-flow") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "canTriggerPortalFlow", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "TriggerPortalFlow", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CanTriggerPortalFlowResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.CanTriggerPortalFlowResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ConfigureDistribution - configureDistribution -// Configure the distribution for the portal's custom domain -func (s *ECPAdmin) ConfigureDistribution(ctx context.Context, request operations.ConfigureDistributionRequest, opts ...operations.Option) (*operations.ConfigureDistributionResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/configure-distribution") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "configureDistribution", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ConfigureDistributionResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ConfigureDistributionResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// CreatePortalConfig - createPortalConfig -// Creates a new portal configuration. -func (s *ECPAdmin) CreatePortalConfig(ctx context.Context, request shared.UpsertPortalConfigV3, opts ...operations.Option) (*operations.CreatePortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v3/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "createPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CreatePortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfigV3 - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfigV3 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 409: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// CreatePortalPage - createPortalPage -// Create a new portal page -func (s *ECPAdmin) CreatePortalPage(ctx context.Context, request operations.CreatePortalPageRequest, opts ...operations.Option) (*operations.CreatePortalPageResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/pages") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "createPortalPage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PageRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CreatePortalPageResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Page = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// CreatePortalPageBlock - createPortalPageBlock -// Create a new portal page block -func (s *ECPAdmin) CreatePortalPageBlock(ctx context.Context, request operations.CreatePortalPageBlockRequest, opts ...operations.Option) (*operations.CreatePortalPageBlockResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "createPortalPageBlock", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "BlockRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CreatePortalPageBlockResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Block = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeletePortal - deletePortal -// Deletes the portal. -func (s *ECPAdmin) DeletePortal(ctx context.Context, request operations.DeletePortalRequest, opts ...operations.Option) (*operations.DeletePortalResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deletePortal", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeletePortalResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeletePortalConfig - deletePortalConfig -// Deletes a specific portal configuration by ID. -func (s *ECPAdmin) DeletePortalConfig(ctx context.Context, request operations.DeletePortalConfigRequest, opts ...operations.Option) (*operations.DeletePortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v3/portal/config/{portal_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deletePortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeletePortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeletePortalPage - deletePortalPage -// Delete a portal page by id -func (s *ECPAdmin) DeletePortalPage(ctx context.Context, request operations.DeletePortalPageRequest, opts ...operations.Option) (*operations.DeletePortalPageResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deletePortalPage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeletePortalPageResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeletePortalPageBlock - deletePortalPageBlock -// Delete a portal page block by id -func (s *ECPAdmin) DeletePortalPageBlock(ctx context.Context, request operations.DeletePortalPageBlockRequest, opts ...operations.Option) (*operations.DeletePortalPageBlockResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks/{block_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deletePortalPageBlock", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeletePortalPageBlockResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ExtraPermissionAttributes - extraPermissionAttributes -// Retrieves the extra permission attributes. -func (s *ECPAdmin) ExtraPermissionAttributes(ctx context.Context, opts ...operations.Option) (*operations.ExtraPermissionAttributesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/extra-permission-attributes") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "extraPermissionAttributes", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ExtraPermissionAttributesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ExtraPermissionAttributesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// FetchPortalUsersByRelatedEntity - fetchPortalUsersByRelatedEntity -// Get all users for a given entity -func (s *ECPAdmin) FetchPortalUsersByRelatedEntity(ctx context.Context, request operations.FetchPortalUsersByRelatedEntityRequest, opts ...operations.Option) (*operations.FetchPortalUsersByRelatedEntityResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/users/by-related-entity") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "fetchPortalUsersByRelatedEntity", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.FetchPortalUsersByRelatedEntityResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.FetchPortalUsersByRelatedEntityResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetAllPortalConfigs - getAllPortalConfigs -// Retrieves all portal configurations. -func (s *ECPAdmin) GetAllPortalConfigs(ctx context.Context, opts ...operations.Option) (*operations.GetAllPortalConfigsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/configs") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getAllPortalConfigs", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetAllPortalConfigsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetAllPortalConfigsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetDefaultPages - getDefaultPages -// Fetch all default portal pages -func (s *ECPAdmin) GetDefaultPages(ctx context.Context, opts ...operations.Option) (*operations.GetDefaultPagesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/pages/default") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getDefaultPages", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetDefaultPagesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetECPContact - getECPContact -// Get the Contact by id -func (s *ECPAdmin) GetECPContact(ctx context.Context, request operations.GetECPContactRequest, opts ...operations.Option) (*operations.GetECPContactResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/ecp/contact") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getECPContact", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetECPContactResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetECPContactResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetEmailTemplates - getEmailTemplates -// Retrieves the email templates of a portal -func (s *ECPAdmin) GetEmailTemplates(ctx context.Context, request operations.GetEmailTemplatesRequest, opts ...operations.Option) (*operations.GetEmailTemplatesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/email-templates") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getEmailTemplates", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetEmailTemplatesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.EmailTemplates - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.EmailTemplates = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetEntityIdentifiers - getEntityIdentifiers -// Retrieve a list of entity identifiers used for entity search by portal users. -func (s *ECPAdmin) GetEntityIdentifiers(ctx context.Context, request operations.GetEntityIdentifiersRequest, opts ...operations.Option) (*operations.GetEntityIdentifiersResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/entity/identifiers/{slug}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getEntityIdentifiers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetEntityIdentifiersResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetEntityIdentifiersResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetExternalLinks - getExternalLinks -// Retrieves the portal configuration external links. -func (s *ECPAdmin) GetExternalLinks(ctx context.Context, request operations.GetExternalLinksRequest, opts ...operations.Option) (*operations.GetExternalLinksResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/external-links") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getExternalLinks", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetExternalLinksResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.ExternalLink - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetOrgPortalConfig - getOrgPortalConfig -// Retrieves the portal configuration for the organization. -func (s *ECPAdmin) GetOrgPortalConfig(ctx context.Context, request operations.GetOrgPortalConfigRequest, opts ...operations.Option) (*operations.GetOrgPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/org/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getOrgPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetOrgPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetOrgPortalConfigResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalConfig - getPortalConfig -// Retrieves the portal configuration. -func (s *ECPAdmin) GetPortalConfig(ctx context.Context, request operations.GetPortalConfigRequest, opts ...operations.Option) (*operations.GetPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfig - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfig = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalConfigV3 - getPortalConfigV3 -// Retrieves a specific portal configuration by ID. -func (s *ECPAdmin) GetPortalConfigV3(ctx context.Context, request operations.GetPortalConfigV3Request, opts ...operations.Option) (*operations.GetPortalConfigV3Response, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v3/portal/config/{portal_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalConfigV3", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalConfigV3Response{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfigV3 - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfigV3 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalExtensions - getPortalExtensions -// Retrieves the installed portal extensions. -func (s *ECPAdmin) GetPortalExtensions(ctx context.Context, request operations.GetPortalExtensionsRequest, opts ...operations.Option) (*operations.GetPortalExtensionsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/extensions") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalExtensions", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalExtensionsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Extension - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPage - getPortalPage -// Fetch a portal page by id -func (s *ECPAdmin) GetPortalPage(ctx context.Context, request operations.GetPortalPageRequest, opts ...operations.Option) (*operations.GetPortalPageResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Page = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPageBlock - getPortalPageBlock -// Fetch a portal page block by id -func (s *ECPAdmin) GetPortalPageBlock(ctx context.Context, request operations.GetPortalPageBlockRequest, opts ...operations.Option) (*operations.GetPortalPageBlockResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks/{block_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPageBlock", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageBlockResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Block = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPageBlocks - getPortalPageBlocks -// Fetch all portal page blocks -func (s *ECPAdmin) GetPortalPageBlocks(ctx context.Context, request operations.GetPortalPageBlocksRequest, opts ...operations.Option) (*operations.GetPortalPageBlocksResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPageBlocks", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPageBlocksResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalPages - getPortalPages -// Fetch all portal pages -func (s *ECPAdmin) GetPortalPages(ctx context.Context, request operations.GetPortalPagesRequest, opts ...operations.Option) (*operations.GetPortalPagesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/pages") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalPages", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalPagesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalWidgets - getPortalWidgets -// Retrieves the widgets of a portal -func (s *ECPAdmin) GetPortalWidgets(ctx context.Context, request operations.GetPortalWidgetsRequest, opts ...operations.Option) (*operations.GetPortalWidgetsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/widgets") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalWidgets", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalWidgetsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.UpsertPortalWidget - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpsertPortalWidget = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetRecipientsToNotifyOnAutomation - getRecipientsToNotifyOnAutomation -// Get recipients to notify on automation -func (s *ECPAdmin) GetRecipientsToNotifyOnAutomation(ctx context.Context, request *operations.GetRecipientsToNotifyOnAutomationRequestBody, opts ...operations.Option) (*operations.GetRecipientsToNotifyOnAutomationResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/recipients-to-notify") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getRecipientsToNotifyOnAutomation", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetRecipientsToNotifyOnAutomationResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetRecipientsToNotifyOnAutomationResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetRegistrationIdentifiers - getRegistrationIdentifiers -// Get valid attributes from entities that can be used as identifier to map contact to user on registration -func (s *ECPAdmin) GetRegistrationIdentifiers(ctx context.Context, opts ...operations.Option) (*operations.GetRegistrationIdentifiersResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/registration/identifiers") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getRegistrationIdentifiers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetRegistrationIdentifiersResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetRegistrationIdentifiersResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetResolvedExternalLink - getResolvedExternalLink -// Retrieves a resolved portal external link. Use /v2/portal/resolve:seamless-link/{id} instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *ECPAdmin) GetResolvedExternalLink(ctx context.Context, request operations.GetResolvedExternalLinkRequest, opts ...operations.Option) (*operations.GetResolvedExternalLinkResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/resolve:external-link/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getResolvedExternalLink", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetResolvedExternalLinkResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ExternalLink - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ExternalLink = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetValidSecondaryAttributes - getValidSecondaryAttributes -// Get valid secondary attributes that are used while mapping a contact on registration -func (s *ECPAdmin) GetValidSecondaryAttributes(ctx context.Context, opts ...operations.Option) (*operations.GetValidSecondaryAttributesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/contact/valid/secondary/attributes") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getValidSecondaryAttributes", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetValidSecondaryAttributesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetValidSecondaryAttributesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ListAllPortalConfigs - listAllPortalConfigs -// Retrieves all portal configurations. -func (s *ECPAdmin) ListAllPortalConfigs(ctx context.Context, opts ...operations.Option) (*operations.ListAllPortalConfigsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v3/portal/configs") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "listAllPortalConfigs", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ListAllPortalConfigsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ListAllPortalConfigsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// LoginToPortalAsUser - loginToPortalAsUser -// Generate a token to log in to a portal impersonating a users. -// -// Token is valid for 5 minutes. -func (s *ECPAdmin) LoginToPortalAsUser(ctx context.Context, request operations.LoginToPortalAsUserRequestBody, opts ...operations.Option) (*operations.LoginToPortalAsUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/admin:login-as-user") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "loginToPortalAsUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.LoginToPortalAsUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.LoginToPortalAsUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// PutPortalConfig - putPortalConfig -// Updates a specific portal configuration by ID. -func (s *ECPAdmin) PutPortalConfig(ctx context.Context, request operations.PutPortalConfigRequest, opts ...operations.Option) (*operations.PutPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v3/portal/config/{portal_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "putPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PortalConfigV3", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.PutPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfigV3 - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfigV3 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ReplaceECPTemplateVariables - replaceECPTemplateVariables -// Replaces the template variables of a portal -func (s *ECPAdmin) ReplaceECPTemplateVariables(ctx context.Context, request map[string]operations.RequestBody, opts ...operations.Option) (*operations.ReplaceECPTemplateVariablesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/replace-ecp-template-variables") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "replaceECPTemplateVariables", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ReplaceECPTemplateVariablesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ReplaceECPTemplateVariablesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ResendConfirmationEmail - resendConfirmationEmail -// Resend confirmation email -func (s *ECPAdmin) ResendConfirmationEmail(ctx context.Context, request operations.ResendConfirmationEmailRequest, opts ...operations.Option) (*operations.ResendConfirmationEmailResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/user/resend/confirmation-email/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "resendConfirmationEmail", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ResendConfirmationEmailResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ResendConfirmationEmailResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SavePortalFiles - savePortalFiles -// Add files to portal -func (s *ECPAdmin) SavePortalFiles(ctx context.Context, request shared.SavePortalFile, opts ...operations.Option) (*operations.SavePortalFilesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/portal/files") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "savePortalFiles", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SavePortalFilesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SavePortalFilesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SwapPortalConfig - swapPortalConfig -// Swaps the portal configuration of two portals. -func (s *ECPAdmin) SwapPortalConfig(ctx context.Context, request operations.SwapPortalConfigRequestBody, opts ...operations.Option) (*operations.SwapPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v3/portal/config/swap") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "swapPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SwapPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SwapPortalConfigResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdatePortalPage - updatePortalPage -// Update a portal page by id -func (s *ECPAdmin) UpdatePortalPage(ctx context.Context, request operations.UpdatePortalPageRequest, opts ...operations.Option) (*operations.UpdatePortalPageResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updatePortalPage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PageRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdatePortalPageResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Page = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdatePortalPageBlock - updatePortalPageBlock -// Update a portal page block by id -func (s *ECPAdmin) UpdatePortalPageBlock(ctx context.Context, request operations.UpdatePortalPageBlockRequest, opts ...operations.Option) (*operations.UpdatePortalPageBlockResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/pages/{id}/blocks/{block_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "updatePortalPageBlock", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "BlockRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpdatePortalPageBlockResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.Block - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Block = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpsertEmailTemplates - upsertEmailTemplates -// Upserts the email templates of a portal -func (s *ECPAdmin) UpsertEmailTemplates(ctx context.Context, request operations.UpsertEmailTemplatesRequest, opts ...operations.Option) (*operations.UpsertEmailTemplatesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/email-templates") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "upsertEmailTemplates", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "EmailTemplates", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpsertEmailTemplatesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UpsertEmailTemplatesResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpsertPortal - upsertPortal -// Upserts the settings for a portal of an organization. -func (s *ECPAdmin) UpsertPortal(ctx context.Context, request operations.UpsertPortalRequest, opts ...operations.Option) (*operations.UpsertPortalResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/portal") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "upsertPortal", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpsertPortalConfig", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpsertPortalResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - fallthrough - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfig - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfig = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpsertPortalWidget - upsertPortalWidget -// Upsert widget for a portal of an organization. -func (s *ECPAdmin) UpsertPortalWidget(ctx context.Context, request operations.UpsertPortalWidgetRequest, opts ...operations.Option) (*operations.UpsertPortalWidgetResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/widgets") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "upsertPortalWidget", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpsertPortalWidget", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UpsertPortalWidgetResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.UpsertPortalWidget - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpsertPortalWidget = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ValidateCaaRecords - validateCaaRecords -// Validates the CAA records of a portal -func (s *ECPAdmin) ValidateCaaRecords(ctx context.Context, request operations.ValidateCaaRecordsRequest, opts ...operations.Option) (*operations.ValidateCaaRecordsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/validate/caa-records") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "validateCaaRecords", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ValidateCaaRecordsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ValidateCaaRecordsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/internal.go b/internal/sdk/internal.go deleted file mode 100644 index 13f66b2..0000000 --- a/internal/sdk/internal.go +++ /dev/null @@ -1,455 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -type Internal struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newInternal(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Internal { - return &Internal{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// GetJuiceSettings - getJuiceSettings -// Retrieves the juice settings by domain. -func (s *Internal) GetJuiceSettings(ctx context.Context, request operations.GetJuiceSettingsRequest, opts ...operations.Option) (*operations.GetJuiceSettingsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/juice-settings") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getJuiceSettings", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetJuiceSettingsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.JuiceSettings - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.JuiceSettings = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ListPortalsInternal - listPortalsInternal -// List all portals (internal API) -func (s *Internal) ListPortalsInternal(ctx context.Context, request operations.ListPortalsInternalRequest, opts ...operations.Option) (*operations.ListPortalsInternalResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/internal") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "listPortalsInternal", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ListPortalsInternalResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ListPortalsInternalResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index 17d3ba5..8ce327f 100644 --- a/internal/sdk/internal/utils/form.go +++ b/internal/sdk/internal/utils/form.go @@ -10,8 +10,7 @@ import ( "strings" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/types" ) @@ -41,8 +40,6 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue formValues.Add(paramName, valToString(objValue.Interface())) case big.Int: formValues.Add(paramName, valToString(objValue.Interface())) - case decimal.Big: - formValues.Add(paramName, valToString(objValue.Interface())) default: var items []string @@ -64,7 +61,13 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue } if explode { - formValues.Add(fieldName, valToString(valType.Interface())) + if valType.Kind() == reflect.Slice || valType.Kind() == reflect.Array { + for i := 0; i < valType.Len(); i++ { + formValues.Add(fieldName, valToString(valType.Index(i).Interface())) + } + } else { + formValues.Add(fieldName, valToString(valType.Interface())) + } } else { items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) } @@ -75,6 +78,16 @@ func populateForm(paramName string, explode bool, objType reflect.Type, objValue } } case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + formValues.Add(paramName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + return formValues + } + items := []string{} iter := objValue.MapRange() diff --git a/internal/sdk/internal/utils/headers.go b/internal/sdk/internal/utils/headers.go index a07608b..5b36059 100644 --- a/internal/sdk/internal/utils/headers.go +++ b/internal/sdk/internal/utils/headers.go @@ -8,6 +8,8 @@ import ( "net/http" "reflect" "strings" + + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/optionalnullable" ) func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { @@ -98,6 +100,16 @@ func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) return strings.Join(items, ",") case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + return valToString(value) + } + // If not set or explicitly null, return empty string + return "" + } + items := []string{} iter := objValue.MapRange() diff --git a/internal/sdk/internal/utils/json.go b/internal/sdk/internal/utils/json.go index a3b707e..493589c 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -15,8 +15,6 @@ import ( "unsafe" "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/types" - - "github.com/ericlagergren/decimal" ) func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { @@ -287,6 +285,11 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) return []byte("null"), nil } + // Check if the map implements json.Marshaler (like optionalnullable.OptionalNullable[T]) + if marshaler, ok := val.Interface().(json.Marshaler); ok { + return marshaler.MarshalJSON() + } + out := map[string]json.RawMessage{} for _, key := range val.MapKeys() { @@ -340,17 +343,6 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) b := val.Interface().(big.Int) return []byte(fmt.Sprintf(`"%s"`, (&b).String())), nil } - case reflect.TypeOf(decimal.Big{}): - format := tag.Get("decimal") - if format == "number" { - b := val.Interface().(decimal.Big) - f, ok := (&b).Float64() - if ok { - return []byte(b.String()), nil - } - - return []byte(fmt.Sprintf(`%f`, f)), nil - } } } @@ -381,11 +373,6 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc if format == "string" { return []byte(fmt.Sprintf(`"%s"`, tagValue)) } - case reflect.TypeOf(decimal.Big{}): - decimalTag := tag.Get("decimal") - if decimalTag != "number" { - return []byte(fmt.Sprintf(`"%s"`, tagValue)) - } case reflect.TypeOf(types.Date{}): return []byte(fmt.Sprintf(`"%s"`, tagValue)) default: @@ -566,27 +553,6 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa v.Set(reflect.ValueOf(b)) return nil - case reflect.TypeOf(decimal.Big{}): - var d *decimal.Big - format := tag.Get("decimal") - if format == "number" { - var ok bool - d, ok = new(decimal.Big).SetString(string(value)) - if !ok { - return fmt.Errorf("failed to parse number as decimal.Big") - } - } else { - if err := json.Unmarshal(value, &d); err != nil { - return err - } - } - - if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { - v = v.Elem() - } - - v.Set(reflect.ValueOf(d)) - return nil case reflect.TypeOf(types.Date{}): var s string @@ -651,8 +617,6 @@ func isComplexValueType(typ reflect.Type) bool { fallthrough case reflect.TypeOf(big.Int{}): fallthrough - case reflect.TypeOf(decimal.Big{}): - fallthrough case reflect.TypeOf(types.Date{}): return true } @@ -672,3 +636,215 @@ func isModelType(typ reflect.Type) bool { return false } + +// CalculateJSONSize returns the byte size of the JSON representation of a value. +// This is used to determine which union type variant has the most data. +func CalculateJSONSize(v interface{}) int { + data, err := json.Marshal(v) + if err != nil { + return 0 + } + return len(data) +} + +// UnionCandidate represents a candidate type during union deserialization +type UnionCandidate struct { + FieldCount int + Size int + Type any // The union type enum value + Value any // The unmarshaled value +} + +// CountFields recursively counts the number of valid (non-nil, non-zero) fields set in a value. +// This is used as the primary discriminator for union types, with JSON size as a tiebreaker. +func CountFields(v interface{}) int { + if v == nil { + return 0 + } + + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + + // Dereference pointers + for typ.Kind() == reflect.Ptr { + if val.IsNil() { + return 0 + } + typ = typ.Elem() + val = val.Elem() + } + + return countFieldsRecursive(typ, val) +} + +// PickBestCandidate selects the best union type candidate using a multi-stage filtering approach: +// 1. If multiple candidates, filter by field count (keep only those with max field count) +// 2. If still multiple, filter by JSON size (keep only those with max size) +// 3. Return the first remaining candidate +func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { + if len(candidates) == 0 { + return nil + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by field count if we have multiple candidates + if len(candidates) > 1 { + maxFieldCount := -1 + for i := range candidates { + candidates[i].FieldCount = CountFields(candidates[i].Value) + if candidates[i].FieldCount > maxFieldCount { + maxFieldCount = candidates[i].FieldCount + } + } + + // Keep only candidates with maximum field count + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.FieldCount == maxFieldCount { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by JSON size if we still have multiple candidates + if len(candidates) > 1 { + maxSize := -1 + for i := range candidates { + candidates[i].Size = CalculateJSONSize(candidates[i].Value) + if candidates[i].Size > maxSize { + maxSize = candidates[i].Size + } + } + + // Keep only candidates with maximum size + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.Size == maxSize { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + // Pick the first remaining candidate + return &candidates[0] +} + +func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { + count := 0 + + switch typ.Kind() { + case reflect.Struct: + // Handle special types + switch typ { + case reflect.TypeOf(time.Time{}): + if !val.Interface().(time.Time).IsZero() { + return 1 + } + return 0 + case reflect.TypeOf(big.Int{}): + b := val.Interface().(big.Int) + if b.Sign() != 0 { + return 1 + } + return 0 + case reflect.TypeOf(types.Date{}): + // Date is always counted if it exists + return 1 + } + + // For regular structs, count non-zero fields + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + // Skip unexported fields and const fields + if !field.IsExported() || field.Tag.Get("const") != "" { + continue + } + + // Skip fields tagged with json:"-" + jsonTag := field.Tag.Get("json") + if jsonTag == "-" { + continue + } + + fieldTyp := field.Type + // Dereference pointer types for the field + for fieldTyp.Kind() == reflect.Ptr { + if fieldVal.IsNil() { + break + } + fieldTyp = fieldTyp.Elem() + fieldVal = fieldVal.Elem() + } + + if !isNil(field.Type, val.Field(i)) { + count += countFieldsRecursive(fieldTyp, fieldVal) + } + } + + case reflect.Slice, reflect.Array: + if val.IsNil() || val.Len() == 0 { + return 0 + } + // Count each array/slice element + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + itemTyp := itemVal.Type() + + // Dereference pointer types + for itemTyp.Kind() == reflect.Ptr { + if itemVal.IsNil() { + break + } + itemTyp = itemTyp.Elem() + itemVal = itemVal.Elem() + } + + if !isNil(itemTyp, itemVal) { + count += countFieldsRecursive(itemTyp, itemVal) + } + } + + case reflect.String: + if val.String() != "" { + count = 1 + } + + case reflect.Bool: + // Bools always count as a field (even if false) + count = 1 + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if val.Int() != 0 { + count = 1 + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if val.Uint() != 0 { + count = 1 + } + + case reflect.Float32, reflect.Float64: + if val.Float() != 0 { + count = 1 + } + + default: + // For any other type, if it's not zero, count it as 1 + if !val.IsZero() { + count = 1 + } + } + + return count +} diff --git a/internal/sdk/internal/utils/pathparams.go b/internal/sdk/internal/utils/pathparams.go index 17114bc..caf48e4 100644 --- a/internal/sdk/internal/utils/pathparams.go +++ b/internal/sdk/internal/utils/pathparams.go @@ -11,8 +11,7 @@ import ( "strings" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/types" ) @@ -114,6 +113,16 @@ func getSimplePathParams(parentName string, objType reflect.Type, objValue refle } pathParams[parentName] = strings.Join(ppVals, ",") case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + pathParams[parentName] = valToString(value) + } + // If not set or explicitly null, return nil (skip parameter) + return pathParams + } + if objValue.Len() == 0 { return nil } @@ -135,8 +144,6 @@ func getSimplePathParams(parentName string, objType reflect.Type, objValue refle pathParams[parentName] = valToString(objValue.Interface()) case big.Int: pathParams[parentName] = valToString(objValue.Interface()) - case decimal.Big: - pathParams[parentName] = valToString(objValue.Interface()) default: var ppVals []string for i := 0; i < objType.NumField(); i++ { diff --git a/internal/sdk/internal/utils/queryparams.go b/internal/sdk/internal/utils/queryparams.go index 1a64dd2..e29b770 100644 --- a/internal/sdk/internal/utils/queryparams.go +++ b/internal/sdk/internal/utils/queryparams.go @@ -12,8 +12,7 @@ import ( "reflect" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/types" ) @@ -157,6 +156,16 @@ func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue refl switch objValue.Kind() { case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + values.Add(tag.ParamName, valToString(value)) + } + // If not set or explicitly null, skip adding to values + return values + } + populateDeepObjectParamsMap(values, tag.ParamName, objValue) case reflect.Struct: populateDeepObjectParamsStruct(values, tag.ParamName, objValue) @@ -235,7 +244,7 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru populateDeepObjectParamsMap(qsValues, scope, fieldValue) case reflect.Struct: switch fieldValue.Type() { - case reflect.TypeOf(big.Int{}), reflect.TypeOf(decimal.Big{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + case reflect.TypeOf(big.Int{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): qsValues.Add(scope, valToString(fieldValue.Interface())) continue diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index 8622ec5..69887e7 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -14,6 +14,8 @@ import ( "path/filepath" "reflect" "regexp" + + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/optionalnullable" ) const ( @@ -340,6 +342,17 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { } } case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(requestValType); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + dataValues.Set(fieldName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + break + } + + // Handle regular map for _, k := range requestValType.MapKeys() { v := requestValType.MapIndex(k) dataValues.Set(fmt.Sprintf("%v", k.Interface()), valToString(v.Interface())) diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index ea624e7..76cbe94 100644 --- a/internal/sdk/internal/utils/utils.go +++ b/internal/sdk/internal/utils/utils.go @@ -14,8 +14,6 @@ import ( "strconv" "strings" "time" - - "github.com/ericlagergren/decimal" ) const ( @@ -183,8 +181,6 @@ func valToString(val interface{}) string { return v.Format(time.RFC3339Nano) case big.Int: return v.String() - case decimal.Big: - return v.String() default: return fmt.Sprintf("%v", v) } diff --git a/internal/sdk/login.go b/internal/sdk/login.go deleted file mode 100644 index 0e996c3..0000000 --- a/internal/sdk/login.go +++ /dev/null @@ -1,245 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -type Login struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newLogin(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Login { - return &Login{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// SsoLogin - ssoLogin -// Initiate login using external SSO identity. -// -// Verifies the user with the issuer and matches the identity to an epilot user (or creates a new user). -// -// Returns parameters to be used with CUSTOM_AUTH flow against Cognito -func (s *Login) SsoLogin(ctx context.Context, request operations.SsoLoginRequest, security operations.SsoLoginSecurity, opts ...operations.Option) (*operations.SsoLoginResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/sso/login") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "ssoLogin", - OAuth2Scopes: nil, - SecuritySource: utils.AsSecuritySource(security), - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - if err := utils.PopulateSecurity(ctx, req, utils.AsSecuritySource(security)); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SsoLoginResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.SsoLoginResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/models/operations/addassignment.go b/internal/sdk/models/operations/addassignment.go new file mode 100644 index 0000000..900becd --- /dev/null +++ b/internal/sdk/models/operations/addassignment.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +type AddAssignmentRequest struct { + RoleID string `pathParam:"style=simple,explode=false,name=roleId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (a *AddAssignmentRequest) GetRoleID() string { + if a == nil { + return "" + } + return a.RoleID +} + +func (a *AddAssignmentRequest) GetUserID() string { + if a == nil { + return "" + } + return a.UserID +} + +type AddAssignmentResponse struct { + // ok + Assignment *shared.Assignment + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (a *AddAssignmentResponse) GetAssignment() *shared.Assignment { + if a == nil { + return nil + } + return a.Assignment +} + +func (a *AddAssignmentResponse) GetContentType() string { + if a == nil { + return "" + } + return a.ContentType +} + +func (a *AddAssignmentResponse) GetStatusCode() int { + if a == nil { + return 0 + } + return a.StatusCode +} + +func (a *AddAssignmentResponse) GetRawResponse() *http.Response { + if a == nil { + return nil + } + return a.RawResponse +} diff --git a/internal/sdk/models/operations/addcontractbyidentifiers.go b/internal/sdk/models/operations/addcontractbyidentifiers.go deleted file mode 100644 index cd7612a..0000000 --- a/internal/sdk/models/operations/addcontractbyidentifiers.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// Reason why the contract is not assignable. If the reason is "MULTIPLE", the contract is not assignable because multiple contracts were found and the business logic does not allow it. -type Reason string - -const ( - ReasonDraft Reason = "DRAFT" - ReasonMultiple Reason = "MULTIPLE" -) - -func (e Reason) ToPointer() *Reason { - return &e -} -func (e *Reason) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "DRAFT": - fallthrough - case "MULTIPLE": - *e = Reason(v) - return nil - default: - return fmt.Errorf("invalid value for Reason: %v", v) - } -} - -// AddContractByIdentifiersECPResponseBody - Contract was found but is not assignable in its current state. -type AddContractByIdentifiersECPResponseBody struct { - // Error message - Message *string `json:"message,omitempty"` - // Reason why the contract is not assignable. If the reason is "MULTIPLE", the contract is not assignable because multiple contracts were found and the business logic does not allow it. - Reason Reason `json:"reason"` -} - -func (o *AddContractByIdentifiersECPResponseBody) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} - -func (o *AddContractByIdentifiersECPResponseBody) GetReason() Reason { - if o == nil { - return Reason("") - } - return o.Reason -} - -// AddContractByIdentifiersResponseBody - Contract(s) assigned successfully. -type AddContractByIdentifiersResponseBody struct { - Data []shared.EntityItem `json:"data,omitempty"` - Hits float64 `json:"hits"` -} - -func (o *AddContractByIdentifiersResponseBody) GetData() []shared.EntityItem { - if o == nil { - return nil - } - return o.Data -} - -func (o *AddContractByIdentifiersResponseBody) GetHits() float64 { - if o == nil { - return 0.0 - } - return o.Hits -} - -type AddContractByIdentifiersResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Contract(s) assigned successfully. - Object *AddContractByIdentifiersResponseBody - // Contract was found but is not assignable in its current state. - Object1 *AddContractByIdentifiersECPResponseBody -} - -func (o *AddContractByIdentifiersResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *AddContractByIdentifiersResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *AddContractByIdentifiersResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *AddContractByIdentifiersResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *AddContractByIdentifiersResponse) GetObject() *AddContractByIdentifiersResponseBody { - if o == nil { - return nil - } - return o.Object -} - -func (o *AddContractByIdentifiersResponse) GetObject1() *AddContractByIdentifiersECPResponseBody { - if o == nil { - return nil - } - return o.Object1 -} diff --git a/internal/sdk/models/operations/assignroles.go b/internal/sdk/models/operations/assignroles.go new file mode 100644 index 0000000..0d200ab --- /dev/null +++ b/internal/sdk/models/operations/assignroles.go @@ -0,0 +1,65 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type AssignRolesRequest struct { + RequestBody []string `request:"mediaType=application/json"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (a *AssignRolesRequest) GetRequestBody() []string { + if a == nil { + return nil + } + return a.RequestBody +} + +func (a *AssignRolesRequest) GetUserID() string { + if a == nil { + return "" + } + return a.UserID +} + +type AssignRolesResponse struct { + // ok + Assignments []string + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (a *AssignRolesResponse) GetAssignments() []string { + if a == nil { + return nil + } + return a.Assignments +} + +func (a *AssignRolesResponse) GetContentType() string { + if a == nil { + return "" + } + return a.ContentType +} + +func (a *AssignRolesResponse) GetStatusCode() int { + if a == nil { + return 0 + } + return a.StatusCode +} + +func (a *AssignRolesResponse) GetRawResponse() *http.Response { + if a == nil { + return nil + } + return a.RawResponse +} diff --git a/internal/sdk/models/operations/cantriggerportalflow.go b/internal/sdk/models/operations/cantriggerportalflow.go deleted file mode 100644 index 1397845..0000000 --- a/internal/sdk/models/operations/cantriggerportalflow.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CanTriggerPortalFlowRequest struct { - // Request of trigger portal flow - TriggerPortalFlow shared.TriggerPortalFlow `request:"mediaType=application/json"` - // Origin of the portal - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - Origin string `queryParam:"style=form,explode=true,name=origin"` - PortalID string `queryParam:"style=form,explode=true,name=portal_id"` -} - -func (o *CanTriggerPortalFlowRequest) GetTriggerPortalFlow() shared.TriggerPortalFlow { - if o == nil { - return shared.TriggerPortalFlow{} - } - return o.TriggerPortalFlow -} - -func (o *CanTriggerPortalFlowRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -func (o *CanTriggerPortalFlowRequest) GetPortalID() string { - if o == nil { - return "" - } - return o.PortalID -} - -// CanTriggerPortalFlowResponseBody - Can Trigger Portal Flow -type CanTriggerPortalFlowResponseBody struct { - // Whether the flow can be triggered - CanTrigger *bool `json:"can_trigger,omitempty"` -} - -func (o *CanTriggerPortalFlowResponseBody) GetCanTrigger() *bool { - if o == nil { - return nil - } - return o.CanTrigger -} - -type CanTriggerPortalFlowResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Can Trigger Portal Flow - Object *CanTriggerPortalFlowResponseBody -} - -func (o *CanTriggerPortalFlowResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CanTriggerPortalFlowResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CanTriggerPortalFlowResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *CanTriggerPortalFlowResponse) GetObject() *CanTriggerPortalFlowResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/checkcontactexists.go b/internal/sdk/models/operations/checkcontactexists.go deleted file mode 100644 index df4bf50..0000000 --- a/internal/sdk/models/operations/checkcontactexists.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CheckContactExistsRequest struct { - // Request payload - ContactExistsRequest shared.ContactExistsRequest `request:"mediaType=application/json"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *CheckContactExistsRequest) GetContactExistsRequest() shared.ContactExistsRequest { - if o == nil { - return shared.ContactExistsRequest{} - } - return o.ContactExistsRequest -} - -func (o *CheckContactExistsRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -// CheckContactExistsResponseBody - Return result true|false if the contact with given identifiers exists. -type CheckContactExistsResponseBody struct { - // Entity ID - ContactID *string `json:"contactId,omitempty"` - // Whether the contact exists with the given identifier values - Exists *bool `json:"exists,omitempty"` -} - -func (o *CheckContactExistsResponseBody) GetContactID() *string { - if o == nil { - return nil - } - return o.ContactID -} - -func (o *CheckContactExistsResponseBody) GetExists() *bool { - if o == nil { - return nil - } - return o.Exists -} - -type CheckContactExistsResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Return result true|false if the contact with given identifiers exists. - Object *CheckContactExistsResponseBody -} - -func (o *CheckContactExistsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CheckContactExistsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CheckContactExistsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CheckContactExistsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *CheckContactExistsResponse) GetObject() *CheckContactExistsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/configuredistribution.go b/internal/sdk/models/operations/configuredistribution.go deleted file mode 100644 index 908880c..0000000 --- a/internal/sdk/models/operations/configuredistribution.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ConfigureDistributionRequest struct { - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *ConfigureDistributionRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -// ConfigureDistributionResponseBody - The cloudfront distribution has been configure successfully for the custom domain. -type ConfigureDistributionResponseBody struct { - // The domain name of the configured distribution - DomainName *string `json:"domainName,omitempty"` -} - -func (o *ConfigureDistributionResponseBody) GetDomainName() *string { - if o == nil { - return nil - } - return o.DomainName -} - -type ConfigureDistributionResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The cloudfront distribution has been configure successfully for the custom domain. - Object *ConfigureDistributionResponseBody -} - -func (o *ConfigureDistributionResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ConfigureDistributionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ConfigureDistributionResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ConfigureDistributionResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ConfigureDistributionResponse) GetObject() *ConfigureDistributionResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/confirmuser.go b/internal/sdk/models/operations/confirmuser.go deleted file mode 100644 index 61b2ef6..0000000 --- a/internal/sdk/models/operations/confirmuser.go +++ /dev/null @@ -1,164 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ConfirmUserRequest struct { - ConfirmationLinkToken string `queryParam:"style=form,explode=true,name=confirmation_link_token"` - UseRedirect *bool `default:"true" queryParam:"style=form,explode=true,name=use_redirect"` -} - -func (c ConfirmUserRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *ConfirmUserRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"confirmation_link_token"}); err != nil { - return err - } - return nil -} - -func (o *ConfirmUserRequest) GetConfirmationLinkToken() string { - if o == nil { - return "" - } - return o.ConfirmationLinkToken -} - -func (o *ConfirmUserRequest) GetUseRedirect() *bool { - if o == nil { - return nil - } - return o.UseRedirect -} - -type ConfirmUserReason string - -const ( - ConfirmUserReasonInvalidToken ConfirmUserReason = "invalid_token" -) - -func (e ConfirmUserReason) ToPointer() *ConfirmUserReason { - return &e -} -func (e *ConfirmUserReason) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "invalid_token": - *e = ConfirmUserReason(v) - return nil - default: - return fmt.Errorf("invalid value for ConfirmUserReason: %v", v) - } -} - -// ConfirmUserPublicResponseBody - The request could not be validated -type ConfirmUserPublicResponseBody struct { - // Error message - Message *string `json:"message,omitempty"` - Reason ConfirmUserReason `json:"reason"` -} - -func (o *ConfirmUserPublicResponseBody) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} - -func (o *ConfirmUserPublicResponseBody) GetReason() ConfirmUserReason { - if o == nil { - return ConfirmUserReason("") - } - return o.Reason -} - -// ConfirmUserResponseBody - Returned in case of successful user confirmation -type ConfirmUserResponseBody struct { - // Is the user confirmed - Confirmed *bool `json:"confirmed,omitempty"` - // Is the user previously confirmed - UserAlreadyConfirmed *bool `json:"user_already_confirmed,omitempty"` -} - -func (o *ConfirmUserResponseBody) GetConfirmed() *bool { - if o == nil { - return nil - } - return o.Confirmed -} - -func (o *ConfirmUserResponseBody) GetUserAlreadyConfirmed() *bool { - if o == nil { - return nil - } - return o.UserAlreadyConfirmed -} - -type ConfirmUserResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Returned in case of successful user confirmation - Object *ConfirmUserResponseBody - // The request could not be validated - Object1 *ConfirmUserPublicResponseBody -} - -func (o *ConfirmUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ConfirmUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ConfirmUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ConfirmUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ConfirmUserResponse) GetObject() *ConfirmUserResponseBody { - if o == nil { - return nil - } - return o.Object -} - -func (o *ConfirmUserResponse) GetObject1() *ConfirmUserPublicResponseBody { - if o == nil { - return nil - } - return o.Object1 -} diff --git a/internal/sdk/models/operations/confirmuserwithuserid.go b/internal/sdk/models/operations/confirmuserwithuserid.go deleted file mode 100644 index fd01218..0000000 --- a/internal/sdk/models/operations/confirmuserwithuserid.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ConfirmUserWithUserIDRequest struct { - // The ID of portal user id - ID string `pathParam:"style=simple,explode=false,name=id"` - // Organization ID - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *ConfirmUserWithUserIDRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ConfirmUserWithUserIDRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *ConfirmUserWithUserIDRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type ConfirmUserWithUserIDResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *ConfirmUserWithUserIDResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ConfirmUserWithUserIDResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ConfirmUserWithUserIDResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ConfirmUserWithUserIDResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/createcustomentityactivity.go b/internal/sdk/models/operations/createcustomentityactivity.go deleted file mode 100644 index f2a7105..0000000 --- a/internal/sdk/models/operations/createcustomentityactivity.go +++ /dev/null @@ -1,116 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// Type - One of supported activity types -type Type string - -const ( - TypePortalUserResetPassword Type = "PortalUserResetPassword" -) - -func (e Type) ToPointer() *Type { - return &e -} -func (e *Type) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PortalUserResetPassword": - *e = Type(v) - return nil - default: - return fmt.Errorf("invalid value for Type: %v", v) - } -} - -type CreateCustomEntityActivityRequestBody struct { - // One of supported activity types - Type Type `json:"type"` -} - -func (o *CreateCustomEntityActivityRequestBody) GetType() Type { - if o == nil { - return Type("") - } - return o.Type -} - -type CreateCustomEntityActivityRequest struct { - RequestBody *CreateCustomEntityActivityRequestBody `request:"mediaType=application/json"` - // Comma-separated list of entities which the activity primarily concerns. Deprecated - ignored as the list of entities is automatically determined now. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - Entities []string `queryParam:"style=form,explode=false,name=entities"` -} - -func (o *CreateCustomEntityActivityRequest) GetRequestBody() *CreateCustomEntityActivityRequestBody { - if o == nil { - return nil - } - return o.RequestBody -} - -func (o *CreateCustomEntityActivityRequest) GetEntities() []string { - if o == nil { - return nil - } - return o.Entities -} - -type CreateCustomEntityActivityResponse struct { - // Success - ActivityItem *shared.ActivityItem - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *CreateCustomEntityActivityResponse) GetActivityItem() *shared.ActivityItem { - if o == nil { - return nil - } - return o.ActivityItem -} - -func (o *CreateCustomEntityActivityResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CreateCustomEntityActivityResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CreateCustomEntityActivityResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CreateCustomEntityActivityResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/createportalconfig.go b/internal/sdk/models/operations/createportalconfig.go deleted file mode 100644 index dc27f5a..0000000 --- a/internal/sdk/models/operations/createportalconfig.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CreatePortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // Portal config created successfully. - PortalConfigV3 *shared.PortalConfigV3 - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *CreatePortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CreatePortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CreatePortalConfigResponse) GetPortalConfigV3() *shared.PortalConfigV3 { - if o == nil { - return nil - } - return o.PortalConfigV3 -} - -func (o *CreatePortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CreatePortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/createportalpage.go b/internal/sdk/models/operations/createportalpage.go deleted file mode 100644 index a0664a9..0000000 --- a/internal/sdk/models/operations/createportalpage.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CreatePortalPageRequest struct { - // The portal page to create - PageRequest shared.PageRequest `request:"mediaType=application/json"` - Domain string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *CreatePortalPageRequest) GetPageRequest() shared.PageRequest { - if o == nil { - return shared.PageRequest{} - } - return o.PageRequest -} - -func (o *CreatePortalPageRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -type CreatePortalPageResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // The portal page has been created successfully. - Page *shared.Page - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *CreatePortalPageResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CreatePortalPageResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CreatePortalPageResponse) GetPage() *shared.Page { - if o == nil { - return nil - } - return o.Page -} - -func (o *CreatePortalPageResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CreatePortalPageResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/createportalpageblock.go b/internal/sdk/models/operations/createportalpageblock.go deleted file mode 100644 index ddcdcd6..0000000 --- a/internal/sdk/models/operations/createportalpageblock.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CreatePortalPageBlockRequest struct { - // The portal page block to create - BlockRequest shared.BlockRequest `request:"mediaType=application/json"` - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *CreatePortalPageBlockRequest) GetBlockRequest() shared.BlockRequest { - if o == nil { - return shared.BlockRequest{} - } - return o.BlockRequest -} - -func (o *CreatePortalPageBlockRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type CreatePortalPageBlockResponse struct { - // The portal page block has been created successfully. - Block *shared.Block - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *CreatePortalPageBlockResponse) GetBlock() *shared.Block { - if o == nil { - return nil - } - return o.Block -} - -func (o *CreatePortalPageBlockResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CreatePortalPageBlockResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CreatePortalPageBlockResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CreatePortalPageBlockResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getcustomerbalance.go b/internal/sdk/models/operations/createrole.go similarity index 51% rename from internal/sdk/models/operations/getcustomerbalance.go rename to internal/sdk/models/operations/createrole.go index ea607f4..2b2b861 100644 --- a/internal/sdk/models/operations/getcustomerbalance.go +++ b/internal/sdk/models/operations/createrole.go @@ -7,41 +7,41 @@ import ( "net/http" ) -type GetCustomerBalanceResponse struct { - // OK - Balance *shared.Balance +type CreateRoleResponse struct { // HTTP response content type for this operation ContentType string + // ok + Role *shared.Role // HTTP response status code for this operation StatusCode int // Raw HTTP response; suitable for custom response parsing RawResponse *http.Response } -func (o *GetCustomerBalanceResponse) GetBalance() *shared.Balance { - if o == nil { - return nil +func (c *CreateRoleResponse) GetContentType() string { + if c == nil { + return "" } - return o.Balance + return c.ContentType } -func (o *GetCustomerBalanceResponse) GetContentType() string { - if o == nil { - return "" +func (c *CreateRoleResponse) GetRole() *shared.Role { + if c == nil { + return nil } - return o.ContentType + return c.Role } -func (o *GetCustomerBalanceResponse) GetStatusCode() int { - if o == nil { +func (c *CreateRoleResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *GetCustomerBalanceResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CreateRoleResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } diff --git a/internal/sdk/models/operations/createuser.go b/internal/sdk/models/operations/createuser.go deleted file mode 100644 index 817211c..0000000 --- a/internal/sdk/models/operations/createuser.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type CreateUserRequest struct { - // Portal user payload - CreateUserRequest shared.CreateUserRequest `request:"mediaType=application/json"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *CreateUserRequest) GetCreateUserRequest() shared.CreateUserRequest { - if o == nil { - return shared.CreateUserRequest{} - } - return o.CreateUserRequest -} - -func (o *CreateUserRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type CreateUserMessage string - -const ( - CreateUserMessageUserCreatedSuccessfully CreateUserMessage = "User created successfully" -) - -func (e CreateUserMessage) ToPointer() *CreateUserMessage { - return &e -} -func (e *CreateUserMessage) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "User created successfully": - *e = CreateUserMessage(v) - return nil - default: - return fmt.Errorf("invalid value for CreateUserMessage: %v", v) - } -} - -// CreateUserResponseBody - User created successfully. -type CreateUserResponseBody struct { - Message CreateUserMessage `json:"message"` -} - -func (o *CreateUserResponseBody) GetMessage() CreateUserMessage { - if o == nil { - return CreateUserMessage("") - } - return o.Message -} - -type CreateUserResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // User created successfully. - Object *CreateUserResponseBody -} - -func (o *CreateUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *CreateUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *CreateUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *CreateUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *CreateUserResponse) GetObject() *CreateUserResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/deleteentityfile.go b/internal/sdk/models/operations/deleteentityfile.go deleted file mode 100644 index e3e5a23..0000000 --- a/internal/sdk/models/operations/deleteentityfile.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// DeleteEntityFileResponseBody - The files are removed from the requested entity successfully. -type DeleteEntityFileResponseBody struct { - DeletedFiles []string `json:"deletedFiles,omitempty"` -} - -func (o *DeleteEntityFileResponseBody) GetDeletedFiles() []string { - if o == nil { - return nil - } - return o.DeletedFiles -} - -type DeleteEntityFileResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The files are removed from the requested entity successfully. - Object *DeleteEntityFileResponseBody -} - -func (o *DeleteEntityFileResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeleteEntityFileResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeleteEntityFileResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeleteEntityFileResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *DeleteEntityFileResponse) GetObject() *DeleteEntityFileResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/deleteportal.go b/internal/sdk/models/operations/deleteportal.go deleted file mode 100644 index d8e8746..0000000 --- a/internal/sdk/models/operations/deleteportal.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeletePortalRequest struct { - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *DeletePortalRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type DeletePortalResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *DeletePortalResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeletePortalResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeletePortalResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeletePortalResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/deleteportalconfig.go b/internal/sdk/models/operations/deleteportalconfig.go deleted file mode 100644 index bdbde0d..0000000 --- a/internal/sdk/models/operations/deleteportalconfig.go +++ /dev/null @@ -1,59 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeletePortalConfigRequest struct { - // Portal ID (readonly UUID generated on portal creation) - PortalID string `pathParam:"style=simple,explode=false,name=portal_id"` -} - -func (o *DeletePortalConfigRequest) GetPortalID() string { - if o == nil { - return "" - } - return o.PortalID -} - -type DeletePortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *DeletePortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeletePortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeletePortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeletePortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/deleteportalpage.go b/internal/sdk/models/operations/deleteportalpage.go deleted file mode 100644 index a36af42..0000000 --- a/internal/sdk/models/operations/deleteportalpage.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeletePortalPageRequest struct { - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *DeletePortalPageRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type DeletePortalPageResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *DeletePortalPageResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeletePortalPageResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeletePortalPageResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeletePortalPageResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/deleteportalpageblock.go b/internal/sdk/models/operations/deleteportalpageblock.go deleted file mode 100644 index b74394c..0000000 --- a/internal/sdk/models/operations/deleteportalpageblock.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeletePortalPageBlockRequest struct { - BlockID string `pathParam:"style=simple,explode=false,name=block_id"` - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *DeletePortalPageBlockRequest) GetBlockID() string { - if o == nil { - return "" - } - return o.BlockID -} - -func (o *DeletePortalPageBlockRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type DeletePortalPageBlockResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *DeletePortalPageBlockResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeletePortalPageBlockResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeletePortalPageBlockResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeletePortalPageBlockResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/deleteportaluser.go b/internal/sdk/models/operations/deleteportaluser.go deleted file mode 100644 index bcdd878..0000000 --- a/internal/sdk/models/operations/deleteportaluser.go +++ /dev/null @@ -1,102 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeletePortalUserMessage string - -const ( - DeletePortalUserMessageUserSuccesfullyDeleted DeletePortalUserMessage = "User Succesfully Deleted" -) - -func (e DeletePortalUserMessage) ToPointer() *DeletePortalUserMessage { - return &e -} -func (e *DeletePortalUserMessage) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "User Succesfully Deleted": - *e = DeletePortalUserMessage(v) - return nil - default: - return fmt.Errorf("invalid value for DeletePortalUserMessage: %v", v) - } -} - -// DeletePortalUserResponseBody - Portal user deleted successfully. -type DeletePortalUserResponseBody struct { - // Entity ID - Data *string `json:"data,omitempty"` - Message *DeletePortalUserMessage `json:"message,omitempty"` -} - -func (o *DeletePortalUserResponseBody) GetData() *string { - if o == nil { - return nil - } - return o.Data -} - -func (o *DeletePortalUserResponseBody) GetMessage() *DeletePortalUserMessage { - if o == nil { - return nil - } - return o.Message -} - -type DeletePortalUserResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal user deleted successfully. - Object *DeletePortalUserResponseBody -} - -func (o *DeletePortalUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeletePortalUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeletePortalUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeletePortalUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *DeletePortalUserResponse) GetObject() *DeletePortalUserResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/deleterole.go b/internal/sdk/models/operations/deleterole.go new file mode 100644 index 0000000..764ce45 --- /dev/null +++ b/internal/sdk/models/operations/deleterole.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +type DeleteRoleRequest struct { + RoleID string `pathParam:"style=simple,explode=false,name=roleId"` +} + +func (d *DeleteRoleRequest) GetRoleID() string { + if d == nil { + return "" + } + return d.RoleID +} + +type DeleteRoleResponse struct { + // HTTP response content type for this operation + ContentType string + // ok + Role *shared.Role + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (d *DeleteRoleResponse) GetContentType() string { + if d == nil { + return "" + } + return d.ContentType +} + +func (d *DeleteRoleResponse) GetRole() *shared.Role { + if d == nil { + return nil + } + return d.Role +} + +func (d *DeleteRoleResponse) GetStatusCode() int { + if d == nil { + return 0 + } + return d.StatusCode +} + +func (d *DeleteRoleResponse) GetRawResponse() *http.Response { + if d == nil { + return nil + } + return d.RawResponse +} diff --git a/internal/sdk/models/operations/deregistermloginuser.go b/internal/sdk/models/operations/deregistermloginuser.go deleted file mode 100644 index 51308d2..0000000 --- a/internal/sdk/models/operations/deregistermloginuser.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type DeRegisterMLoginUserRequest struct { - // Client ID - ClientID string `pathParam:"style=simple,explode=false,name=client_id"` - // User ID - UserID string `pathParam:"style=simple,explode=false,name=user_id"` -} - -func (o *DeRegisterMLoginUserRequest) GetClientID() string { - if o == nil { - return "" - } - return o.ClientID -} - -func (o *DeRegisterMLoginUserRequest) GetUserID() string { - if o == nil { - return "" - } - return o.UserID -} - -type DeRegisterMLoginUserResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *DeRegisterMLoginUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *DeRegisterMLoginUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *DeRegisterMLoginUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *DeRegisterMLoginUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/extrapermissionattributes.go b/internal/sdk/models/operations/extrapermissionattributes.go deleted file mode 100644 index c76678e..0000000 --- a/internal/sdk/models/operations/extrapermissionattributes.go +++ /dev/null @@ -1,119 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type Data struct { - Contact []shared.ExtraSchemaAttributes `json:"contact,omitempty"` - Contract []shared.ExtraSchemaAttributes `json:"contract,omitempty"` - Meter []shared.ExtraSchemaAttributes `json:"meter,omitempty"` - MeterCounter []shared.ExtraSchemaAttributes `json:"meter_counter,omitempty"` - Opportunity []shared.ExtraSchemaAttributes `json:"opportunity,omitempty"` - Order []shared.ExtraSchemaAttributes `json:"order,omitempty"` -} - -func (o *Data) GetContact() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.Contact -} - -func (o *Data) GetContract() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.Contract -} - -func (o *Data) GetMeter() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.Meter -} - -func (o *Data) GetMeterCounter() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.MeterCounter -} - -func (o *Data) GetOpportunity() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.Opportunity -} - -func (o *Data) GetOrder() []shared.ExtraSchemaAttributes { - if o == nil { - return nil - } - return o.Order -} - -// ExtraPermissionAttributesResponseBody - Retrieved extra permission attributes successfully. -type ExtraPermissionAttributesResponseBody struct { - Data *Data `json:"data,omitempty"` -} - -func (o *ExtraPermissionAttributesResponseBody) GetData() *Data { - if o == nil { - return nil - } - return o.Data -} - -type ExtraPermissionAttributesResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved extra permission attributes successfully. - Object *ExtraPermissionAttributesResponseBody -} - -func (o *ExtraPermissionAttributesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ExtraPermissionAttributesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ExtraPermissionAttributesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ExtraPermissionAttributesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ExtraPermissionAttributesResponse) GetObject() *ExtraPermissionAttributesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/fetchportalusersbyrelatedentity.go b/internal/sdk/models/operations/fetchportalusersbyrelatedentity.go deleted file mode 100644 index 480aebc..0000000 --- a/internal/sdk/models/operations/fetchportalusersbyrelatedentity.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type FetchPortalUsersByRelatedEntityRequest struct { - EntityID string `queryParam:"style=form,explode=true,name=entity_id"` - // URL-friendly identifier for the entity schema - Slug shared.EntitySlug `queryParam:"style=form,explode=true,name=slug"` -} - -func (o *FetchPortalUsersByRelatedEntityRequest) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *FetchPortalUsersByRelatedEntityRequest) GetSlug() shared.EntitySlug { - if o == nil { - return shared.EntitySlug("") - } - return o.Slug -} - -// FetchPortalUsersByRelatedEntityResponseBody - Returns the portal users under the given entity. -type FetchPortalUsersByRelatedEntityResponseBody struct { - PortalUsers []shared.PortalUser `json:"portalUsers,omitempty"` -} - -func (o *FetchPortalUsersByRelatedEntityResponseBody) GetPortalUsers() []shared.PortalUser { - if o == nil { - return nil - } - return o.PortalUsers -} - -type FetchPortalUsersByRelatedEntityResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Returns the portal users under the given entity. - Object *FetchPortalUsersByRelatedEntityResponseBody -} - -func (o *FetchPortalUsersByRelatedEntityResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *FetchPortalUsersByRelatedEntityResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *FetchPortalUsersByRelatedEntityResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *FetchPortalUsersByRelatedEntityResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *FetchPortalUsersByRelatedEntityResponse) GetObject() *FetchPortalUsersByRelatedEntityResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallcontracts.go b/internal/sdk/models/operations/getallcontracts.go deleted file mode 100644 index a48eb48..0000000 --- a/internal/sdk/models/operations/getallcontracts.go +++ /dev/null @@ -1,562 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -type GetAllContractsRequest struct { - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"100" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetAllContractsRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllContractsRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetAllContractsRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetAllContractsRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -// BillingPeriod - The billing period associated with the contract. -type BillingPeriod string - -const ( - BillingPeriodWeekly BillingPeriod = "weekly" - BillingPeriodMonthly BillingPeriod = "monthly" - BillingPeriodEveryQuarter BillingPeriod = "every_quarter" - BillingPeriodEvery6Months BillingPeriod = "every_6_months" - BillingPeriodYearly BillingPeriod = "yearly" -) - -func (e BillingPeriod) ToPointer() *BillingPeriod { - return &e -} -func (e *BillingPeriod) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weekly": - fallthrough - case "monthly": - fallthrough - case "every_quarter": - fallthrough - case "every_6_months": - fallthrough - case "yearly": - *e = BillingPeriod(v) - return nil - default: - return fmt.Errorf("invalid value for BillingPeriod: %v", v) - } -} - -// Branch - The branch associated with the contract. -type Branch string - -const ( - BranchPower Branch = "power" - BranchGas Branch = "gas" - BranchWater Branch = "water" - BranchWasteWater Branch = "waste_water" - BranchDistrictHeating Branch = "district_heating" -) - -func (e Branch) ToPointer() *Branch { - return &e -} -func (e *Branch) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "power": - fallthrough - case "gas": - fallthrough - case "water": - fallthrough - case "waste_water": - fallthrough - case "district_heating": - *e = Branch(v) - return nil - default: - return fmt.Errorf("invalid value for Branch: %v", v) - } -} - -// NoticeTimeUnit - The unit of time for the notice period. -type NoticeTimeUnit string - -const ( - NoticeTimeUnitWeeks NoticeTimeUnit = "weeks" - NoticeTimeUnitMonths NoticeTimeUnit = "months" - NoticeTimeUnitYears NoticeTimeUnit = "years" -) - -func (e NoticeTimeUnit) ToPointer() *NoticeTimeUnit { - return &e -} -func (e *NoticeTimeUnit) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weeks": - fallthrough - case "months": - fallthrough - case "years": - *e = NoticeTimeUnit(v) - return nil - default: - return fmt.Errorf("invalid value for NoticeTimeUnit: %v", v) - } -} - -// RenewalDurationUnit - The unit of time for the renewal period. -type RenewalDurationUnit string - -const ( - RenewalDurationUnitWeeks RenewalDurationUnit = "weeks" - RenewalDurationUnitMonths RenewalDurationUnit = "months" - RenewalDurationUnitYears RenewalDurationUnit = "years" -) - -func (e RenewalDurationUnit) ToPointer() *RenewalDurationUnit { - return &e -} -func (e *RenewalDurationUnit) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weeks": - fallthrough - case "months": - fallthrough - case "years": - *e = RenewalDurationUnit(v) - return nil - default: - return fmt.Errorf("invalid value for RenewalDurationUnit: %v", v) - } -} - -// GetAllContractsStatus - The status of the contract. -type GetAllContractsStatus string - -const ( - GetAllContractsStatusDraft GetAllContractsStatus = "draft" - GetAllContractsStatusInApprovalProcess GetAllContractsStatus = "in_approval_process" - GetAllContractsStatusApproved GetAllContractsStatus = "approved" - GetAllContractsStatusActive GetAllContractsStatus = "active" - GetAllContractsStatusDeactivated GetAllContractsStatus = "deactivated" - GetAllContractsStatusRevoked GetAllContractsStatus = "revoked" - GetAllContractsStatusTerminated GetAllContractsStatus = "terminated" - GetAllContractsStatusExpired GetAllContractsStatus = "expired" -) - -func (e GetAllContractsStatus) ToPointer() *GetAllContractsStatus { - return &e -} -func (e *GetAllContractsStatus) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "draft": - fallthrough - case "in_approval_process": - fallthrough - case "approved": - fallthrough - case "active": - fallthrough - case "deactivated": - fallthrough - case "revoked": - fallthrough - case "terminated": - fallthrough - case "expired": - *e = GetAllContractsStatus(v) - return nil - default: - return fmt.Errorf("invalid value for GetAllContractsStatus: %v", v) - } -} - -// GetAllContractsData - The contract entity -type GetAllContractsData struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - // The account number associated with the contract. - AccountNumber *string `json:"account_number,omitempty"` - // Any additional addresses associated with the contract. - AdditionalAddresses *string `json:"additional_addresses,omitempty"` - // Current balance of the contract in cents. (precision 2) - Balance *int64 `json:"balance,omitempty"` - // Currency code in ISO 4217 format - BalanceCurrency *string `json:"balance_currency,omitempty"` - // The billing address associated with the contract. - BillingAddress *string `json:"billing_address,omitempty"` - // Defines the day of the month in which the installments are due. - BillingDueDay *int64 `json:"billing_due_day,omitempty"` - // The duration of the billing period. - BillingDurationAmount *float64 `json:"billing_duration_amount,omitempty"` - // The billing period associated with the contract. - BillingPeriod *BillingPeriod `default:"weekly" json:"billing_period"` - // The branch associated with the contract. - Branch *Branch `json:"branch,omitempty"` - // The name of the contract. - ContractName *string `json:"contract_name,omitempty"` - // The unique identifier of the contract. - ContractNumber *string `json:"contract_number,omitempty"` - // The delivery address associated with the contract. - DeliveryAddress *string `json:"delivery_address,omitempty"` - // A brief description of the contract. - Description *string `json:"description,omitempty"` - // Set amount for installments in cents. (precision 2) - InstallmentAmount *int64 `json:"installment_amount,omitempty"` - JourneyActions *shared.JourneyActions `json:"journey_actions,omitempty"` - // The amount of notice required for termination of the contract. - NoticeTimeAmount *float64 `json:"notice_time_amount,omitempty"` - // The unit of time for the notice period. - NoticeTimeUnit *NoticeTimeUnit `default:"months" json:"notice_time_unit"` - // The duration of the renewal period. - RenewalDurationAmount *float64 `json:"renewal_duration_amount,omitempty"` - // The unit of time for the renewal period. - RenewalDurationUnit *RenewalDurationUnit `default:"months" json:"renewal_duration_unit"` - // The start date of the contract. - StartDate *string `json:"start_date,omitempty"` - // The status of the contract. - Status *GetAllContractsStatus `default:"draft" json:"status"` - // The date on which the contract was terminated. - TerminationDate *string `json:"termination_date,omitempty"` - // The reason for the termination of the contract. - TerminationReason *string `json:"termination_reason,omitempty"` -} - -func (g GetAllContractsData) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllContractsData) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"_created_at", "_id", "_org", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *GetAllContractsData) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *GetAllContractsData) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *GetAllContractsData) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *GetAllContractsData) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *GetAllContractsData) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *GetAllContractsData) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *GetAllContractsData) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *GetAllContractsData) GetAccountNumber() *string { - if o == nil { - return nil - } - return o.AccountNumber -} - -func (o *GetAllContractsData) GetAdditionalAddresses() *string { - if o == nil { - return nil - } - return o.AdditionalAddresses -} - -func (o *GetAllContractsData) GetBalance() *int64 { - if o == nil { - return nil - } - return o.Balance -} - -func (o *GetAllContractsData) GetBalanceCurrency() *string { - if o == nil { - return nil - } - return o.BalanceCurrency -} - -func (o *GetAllContractsData) GetBillingAddress() *string { - if o == nil { - return nil - } - return o.BillingAddress -} - -func (o *GetAllContractsData) GetBillingDueDay() *int64 { - if o == nil { - return nil - } - return o.BillingDueDay -} - -func (o *GetAllContractsData) GetBillingDurationAmount() *float64 { - if o == nil { - return nil - } - return o.BillingDurationAmount -} - -func (o *GetAllContractsData) GetBillingPeriod() *BillingPeriod { - if o == nil { - return nil - } - return o.BillingPeriod -} - -func (o *GetAllContractsData) GetBranch() *Branch { - if o == nil { - return nil - } - return o.Branch -} - -func (o *GetAllContractsData) GetContractName() *string { - if o == nil { - return nil - } - return o.ContractName -} - -func (o *GetAllContractsData) GetContractNumber() *string { - if o == nil { - return nil - } - return o.ContractNumber -} - -func (o *GetAllContractsData) GetDeliveryAddress() *string { - if o == nil { - return nil - } - return o.DeliveryAddress -} - -func (o *GetAllContractsData) GetDescription() *string { - if o == nil { - return nil - } - return o.Description -} - -func (o *GetAllContractsData) GetInstallmentAmount() *int64 { - if o == nil { - return nil - } - return o.InstallmentAmount -} - -func (o *GetAllContractsData) GetJourneyActions() *shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -func (o *GetAllContractsData) GetNoticeTimeAmount() *float64 { - if o == nil { - return nil - } - return o.NoticeTimeAmount -} - -func (o *GetAllContractsData) GetNoticeTimeUnit() *NoticeTimeUnit { - if o == nil { - return nil - } - return o.NoticeTimeUnit -} - -func (o *GetAllContractsData) GetRenewalDurationAmount() *float64 { - if o == nil { - return nil - } - return o.RenewalDurationAmount -} - -func (o *GetAllContractsData) GetRenewalDurationUnit() *RenewalDurationUnit { - if o == nil { - return nil - } - return o.RenewalDurationUnit -} - -func (o *GetAllContractsData) GetStartDate() *string { - if o == nil { - return nil - } - return o.StartDate -} - -func (o *GetAllContractsData) GetStatus() *GetAllContractsStatus { - if o == nil { - return nil - } - return o.Status -} - -func (o *GetAllContractsData) GetTerminationDate() *string { - if o == nil { - return nil - } - return o.TerminationDate -} - -func (o *GetAllContractsData) GetTerminationReason() *string { - if o == nil { - return nil - } - return o.TerminationReason -} - -// GetAllContractsResponseBody - Contracts have been retrieved successfully. -type GetAllContractsResponseBody struct { - Data []GetAllContractsData `json:"data,omitempty"` -} - -func (o *GetAllContractsResponseBody) GetData() []GetAllContractsData { - if o == nil { - return nil - } - return o.Data -} - -type GetAllContractsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Contracts have been retrieved successfully. - Object *GetAllContractsResponseBody -} - -func (o *GetAllContractsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllContractsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllContractsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllContractsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllContractsResponse) GetObject() *GetAllContractsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallfiles.go b/internal/sdk/models/operations/getallfiles.go deleted file mode 100644 index 376aa22..0000000 --- a/internal/sdk/models/operations/getallfiles.go +++ /dev/null @@ -1,114 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetAllFilesRequest struct { - // List of entity ids to filter the results - EntityIds []string `queryParam:"style=form,explode=true,name=entity_ids"` - // List of `File.type`'s to filter the results - FileTypes []string `queryParam:"style=form,explode=true,name=file_types"` - From float64 `queryParam:"style=form,explode=true,name=from"` - Size float64 `queryParam:"style=form,explode=true,name=size"` -} - -func (o *GetAllFilesRequest) GetEntityIds() []string { - if o == nil { - return nil - } - return o.EntityIds -} - -func (o *GetAllFilesRequest) GetFileTypes() []string { - if o == nil { - return nil - } - return o.FileTypes -} - -func (o *GetAllFilesRequest) GetFrom() float64 { - if o == nil { - return 0.0 - } - return o.From -} - -func (o *GetAllFilesRequest) GetSize() float64 { - if o == nil { - return 0.0 - } - return o.Size -} - -// GetAllFilesResponseBody - The files have been fetched successfully. -type GetAllFilesResponseBody struct { - // Total number of files for pagination - Hits *float64 `json:"hits,omitempty"` - Results []shared.FileItem `json:"results,omitempty"` -} - -func (o *GetAllFilesResponseBody) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *GetAllFilesResponseBody) GetResults() []shared.FileItem { - if o == nil { - return nil - } - return o.Results -} - -type GetAllFilesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The files have been fetched successfully. - Object *GetAllFilesResponseBody -} - -func (o *GetAllFilesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllFilesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllFilesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllFilesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllFilesResponse) GetObject() *GetAllFilesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallopportunities.go b/internal/sdk/models/operations/getallopportunities.go deleted file mode 100644 index c57a518..0000000 --- a/internal/sdk/models/operations/getallopportunities.go +++ /dev/null @@ -1,218 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -type GetAllOpportunitiesRequest struct { - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"100" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetAllOpportunitiesRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllOpportunitiesRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetAllOpportunitiesRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetAllOpportunitiesRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -type GetAllOpportunitiesSchema string - -const ( - GetAllOpportunitiesSchemaOpportunity GetAllOpportunitiesSchema = "opportunity" -) - -func (e GetAllOpportunitiesSchema) ToPointer() *GetAllOpportunitiesSchema { - return &e -} -func (e *GetAllOpportunitiesSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "opportunity": - *e = GetAllOpportunitiesSchema(v) - return nil - default: - return fmt.Errorf("invalid value for GetAllOpportunitiesSchema: %v", v) - } -} - -// GetAllOpportunitiesData - The opportunity entity -type GetAllOpportunitiesData struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema GetAllOpportunitiesSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - JourneyActions *shared.JourneyActions `json:"journey_actions,omitempty"` -} - -func (g GetAllOpportunitiesData) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllOpportunitiesData) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *GetAllOpportunitiesData) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *GetAllOpportunitiesData) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *GetAllOpportunitiesData) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *GetAllOpportunitiesData) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *GetAllOpportunitiesData) GetSchema() GetAllOpportunitiesSchema { - if o == nil { - return GetAllOpportunitiesSchema("") - } - return o.Schema -} - -func (o *GetAllOpportunitiesData) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *GetAllOpportunitiesData) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *GetAllOpportunitiesData) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *GetAllOpportunitiesData) GetJourneyActions() *shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -// GetAllOpportunitiesResponseBody - The opportunities is retrieved successfully for the portal user. -type GetAllOpportunitiesResponseBody struct { - Data []GetAllOpportunitiesData `json:"data,omitempty"` -} - -func (o *GetAllOpportunitiesResponseBody) GetData() []GetAllOpportunitiesData { - if o == nil { - return nil - } - return o.Data -} - -type GetAllOpportunitiesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The opportunities is retrieved successfully for the portal user. - Object *GetAllOpportunitiesResponseBody -} - -func (o *GetAllOpportunitiesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllOpportunitiesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllOpportunitiesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllOpportunitiesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllOpportunitiesResponse) GetObject() *GetAllOpportunitiesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallorders.go b/internal/sdk/models/operations/getallorders.go deleted file mode 100644 index 48138e5..0000000 --- a/internal/sdk/models/operations/getallorders.go +++ /dev/null @@ -1,218 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -type GetAllOrdersRequest struct { - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"100" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetAllOrdersRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllOrdersRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetAllOrdersRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetAllOrdersRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -type GetAllOrdersSchema string - -const ( - GetAllOrdersSchemaOrder GetAllOrdersSchema = "order" -) - -func (e GetAllOrdersSchema) ToPointer() *GetAllOrdersSchema { - return &e -} -func (e *GetAllOrdersSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "order": - *e = GetAllOrdersSchema(v) - return nil - default: - return fmt.Errorf("invalid value for GetAllOrdersSchema: %v", v) - } -} - -// GetAllOrdersData - The order entity -type GetAllOrdersData struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema GetAllOrdersSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - JourneyActions *shared.JourneyActions `json:"journey_actions,omitempty"` -} - -func (g GetAllOrdersData) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllOrdersData) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *GetAllOrdersData) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *GetAllOrdersData) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *GetAllOrdersData) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *GetAllOrdersData) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *GetAllOrdersData) GetSchema() GetAllOrdersSchema { - if o == nil { - return GetAllOrdersSchema("") - } - return o.Schema -} - -func (o *GetAllOrdersData) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *GetAllOrdersData) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *GetAllOrdersData) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *GetAllOrdersData) GetJourneyActions() *shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -// GetAllOrdersResponseBody - The orders for the portal user returned successfully. -type GetAllOrdersResponseBody struct { - Data []GetAllOrdersData `json:"data,omitempty"` -} - -func (o *GetAllOrdersResponseBody) GetData() []GetAllOrdersData { - if o == nil { - return nil - } - return o.Data -} - -type GetAllOrdersResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The orders for the portal user returned successfully. - Object *GetAllOrdersResponseBody -} - -func (o *GetAllOrdersResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllOrdersResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllOrdersResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllOrdersResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllOrdersResponse) GetObject() *GetAllOrdersResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallportalconfigs.go b/internal/sdk/models/operations/getallportalconfigs.go deleted file mode 100644 index 4502e45..0000000 --- a/internal/sdk/models/operations/getallportalconfigs.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetAllPortalConfigsResponseBody - All portal configs retrieved successfully. -type GetAllPortalConfigsResponseBody struct { - Data []shared.PortalConfig `json:"data,omitempty"` -} - -func (o *GetAllPortalConfigsResponseBody) GetData() []shared.PortalConfig { - if o == nil { - return nil - } - return o.Data -} - -type GetAllPortalConfigsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // All portal configs retrieved successfully. - Object *GetAllPortalConfigsResponseBody -} - -func (o *GetAllPortalConfigsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllPortalConfigsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllPortalConfigsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllPortalConfigsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllPortalConfigsResponse) GetObject() *GetAllPortalConfigsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getallrequests.go b/internal/sdk/models/operations/getallrequests.go deleted file mode 100644 index 2290f1a..0000000 --- a/internal/sdk/models/operations/getallrequests.go +++ /dev/null @@ -1,407 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -type GetAllRequestsRequest struct { - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"200" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetAllRequestsRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetAllRequestsRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetAllRequestsRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetAllRequestsRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -type OrderSchema string - -const ( - OrderSchemaOrder OrderSchema = "order" -) - -func (e OrderSchema) ToPointer() *OrderSchema { - return &e -} -func (e *OrderSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "order": - *e = OrderSchema(v) - return nil - default: - return fmt.Errorf("invalid value for OrderSchema: %v", v) - } -} - -// OrderSchemas - The order entity -type OrderSchemas struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema OrderSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - JourneyActions *shared.JourneyActions `json:"journey_actions,omitempty"` -} - -func (o OrderSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(o, "", false) -} - -func (o *OrderSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *OrderSchemas) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *OrderSchemas) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *OrderSchemas) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *OrderSchemas) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *OrderSchemas) GetSchema() OrderSchema { - if o == nil { - return OrderSchema("") - } - return o.Schema -} - -func (o *OrderSchemas) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *OrderSchemas) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *OrderSchemas) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *OrderSchemas) GetJourneyActions() *shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -type Schema string - -const ( - SchemaOpportunity Schema = "opportunity" -) - -func (e Schema) ToPointer() *Schema { - return &e -} -func (e *Schema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "opportunity": - *e = Schema(v) - return nil - default: - return fmt.Errorf("invalid value for Schema: %v", v) - } -} - -// Schemas - The opportunity entity -type Schemas struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema Schema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - JourneyActions *shared.JourneyActions `json:"journey_actions,omitempty"` -} - -func (s Schemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *Schemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Schemas) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Schemas) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Schemas) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Schemas) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Schemas) GetSchema() Schema { - if o == nil { - return Schema("") - } - return o.Schema -} - -func (o *Schemas) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Schemas) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Schemas) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *Schemas) GetJourneyActions() *shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -type ResultsType string - -const ( - ResultsTypeSchemas ResultsType = "Schemas" - ResultsTypeOrderSchemas ResultsType = "Order_Schemas" -) - -type Results struct { - Schemas *Schemas `queryParam:"inline" name:"results"` - OrderSchemas *OrderSchemas `queryParam:"inline" name:"results"` - - Type ResultsType -} - -func CreateResultsSchemas(schemas Schemas) Results { - typ := ResultsTypeSchemas - - return Results{ - Schemas: &schemas, - Type: typ, - } -} - -func CreateResultsOrderSchemas(orderSchemas OrderSchemas) Results { - typ := ResultsTypeOrderSchemas - - return Results{ - OrderSchemas: &orderSchemas, - Type: typ, - } -} - -func (u *Results) UnmarshalJSON(data []byte) error { - - var schemas Schemas = Schemas{} - if err := utils.UnmarshalJSON(data, &schemas, "", true, nil); err == nil { - u.Schemas = &schemas - u.Type = ResultsTypeSchemas - return nil - } - - var orderSchemas OrderSchemas = OrderSchemas{} - if err := utils.UnmarshalJSON(data, &orderSchemas, "", true, nil); err == nil { - u.OrderSchemas = &orderSchemas - u.Type = ResultsTypeOrderSchemas - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for Results", string(data)) -} - -func (u Results) MarshalJSON() ([]byte, error) { - if u.Schemas != nil { - return utils.MarshalJSON(u.Schemas, "", true) - } - - if u.OrderSchemas != nil { - return utils.MarshalJSON(u.OrderSchemas, "", true) - } - - return nil, errors.New("could not marshal union type Results: all fields are null") -} - -// GetAllRequestsResponseBody - The opportunities is retrieved successfully for the portal user. -type GetAllRequestsResponseBody struct { - // Total number of hits - Hits *float64 `json:"hits,omitempty"` - Results []Results `json:"results,omitempty"` -} - -func (o *GetAllRequestsResponseBody) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *GetAllRequestsResponseBody) GetResults() []Results { - if o == nil { - return nil - } - return o.Results -} - -type GetAllRequestsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The opportunities is retrieved successfully for the portal user. - Object *GetAllRequestsResponseBody -} - -func (o *GetAllRequestsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAllRequestsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAllRequestsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAllRequestsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAllRequestsResponse) GetObject() *GetAllRequestsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getassignedrolesforuser.go b/internal/sdk/models/operations/getassignedrolesforuser.go new file mode 100644 index 0000000..a78227f --- /dev/null +++ b/internal/sdk/models/operations/getassignedrolesforuser.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type GetAssignedRolesForUserRequest struct { + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (g *GetAssignedRolesForUserRequest) GetUserID() string { + if g == nil { + return "" + } + return g.UserID +} + +type GetAssignedRolesForUserResponse struct { + // ok + Assignments []string + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (g *GetAssignedRolesForUserResponse) GetAssignments() []string { + if g == nil { + return nil + } + return g.Assignments +} + +func (g *GetAssignedRolesForUserResponse) GetContentType() string { + if g == nil { + return "" + } + return g.ContentType +} + +func (g *GetAssignedRolesForUserResponse) GetStatusCode() int { + if g == nil { + return 0 + } + return g.StatusCode +} + +func (g *GetAssignedRolesForUserResponse) GetRawResponse() *http.Response { + if g == nil { + return nil + } + return g.RawResponse +} diff --git a/internal/sdk/models/operations/getautomationcontext.go b/internal/sdk/models/operations/getautomationcontext.go deleted file mode 100644 index 646a0df..0000000 --- a/internal/sdk/models/operations/getautomationcontext.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// QueryParamType - Type of the context to retrieve -type QueryParamType string - -const ( - QueryParamTypeFile QueryParamType = "file" -) - -func (e QueryParamType) ToPointer() *QueryParamType { - return &e -} -func (e *QueryParamType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "file": - *e = QueryParamType(v) - return nil - default: - return fmt.Errorf("invalid value for QueryParamType: %v", v) - } -} - -type GetAutomationContextRequest struct { - // Activity ID - ActivityID string `queryParam:"style=form,explode=true,name=activity_id"` - // Type of the context to retrieve - Type QueryParamType `queryParam:"style=form,explode=true,name=type"` -} - -func (o *GetAutomationContextRequest) GetActivityID() string { - if o == nil { - return "" - } - return o.ActivityID -} - -func (o *GetAutomationContextRequest) GetType() QueryParamType { - if o == nil { - return QueryParamType("") - } - return o.Type -} - -type GetAutomationContextResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved the automation context successfully. - Object map[string]map[string]any -} - -func (o *GetAutomationContextResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetAutomationContextResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetAutomationContextResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetAutomationContextResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetAutomationContextResponse) GetObject() map[string]map[string]any { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getbillingevents.go b/internal/sdk/models/operations/getbillingevents.go deleted file mode 100644 index aac6b47..0000000 --- a/internal/sdk/models/operations/getbillingevents.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -// EventType - Type of billing event to filter by -type EventType string - -const ( - EventTypeInstallment EventType = "installment" - EventTypeReimbursement EventType = "reimbursement" -) - -func (e EventType) ToPointer() *EventType { - return &e -} -func (e *EventType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "installment": - fallthrough - case "reimbursement": - *e = EventType(v) - return nil - default: - return fmt.Errorf("invalid value for EventType: %v", v) - } -} - -type GetBillingEventsRequest struct { - DateAfter *time.Time `queryParam:"style=form,explode=true,name=date_after"` - DateBefore *time.Time `queryParam:"style=form,explode=true,name=date_before"` - // Entity ID to filter billing events by - EntityID []string `queryParam:"style=form,explode=true,name=entity_id"` - // Type of billing event to filter by - EventType *EventType `queryParam:"style=form,explode=true,name=event_type"` - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Paid *bool `queryParam:"style=form,explode=true,name=paid"` - Size *float64 `default:"100" queryParam:"style=form,explode=true,name=size"` - Sort *string `queryParam:"style=form,explode=true,name=sort"` -} - -func (g GetBillingEventsRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetBillingEventsRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetBillingEventsRequest) GetDateAfter() *time.Time { - if o == nil { - return nil - } - return o.DateAfter -} - -func (o *GetBillingEventsRequest) GetDateBefore() *time.Time { - if o == nil { - return nil - } - return o.DateBefore -} - -func (o *GetBillingEventsRequest) GetEntityID() []string { - if o == nil { - return nil - } - return o.EntityID -} - -func (o *GetBillingEventsRequest) GetEventType() *EventType { - if o == nil { - return nil - } - return o.EventType -} - -func (o *GetBillingEventsRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetBillingEventsRequest) GetPaid() *bool { - if o == nil { - return nil - } - return o.Paid -} - -func (o *GetBillingEventsRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -func (o *GetBillingEventsRequest) GetSort() *string { - if o == nil { - return nil - } - return o.Sort -} - -// GetBillingEventsResponseBody - List billing events for all contracts/orders of specific customer -type GetBillingEventsResponseBody struct { - // Total number of billing events for pagination - Hits *float64 `json:"hits,omitempty"` - Results []shared.BillingEvent `json:"results,omitempty"` -} - -func (o *GetBillingEventsResponseBody) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *GetBillingEventsResponseBody) GetResults() []shared.BillingEvent { - if o == nil { - return nil - } - return o.Results -} - -type GetBillingEventsResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // List billing events for all contracts/orders of specific customer - Object *GetBillingEventsResponseBody -} - -func (o *GetBillingEventsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetBillingEventsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetBillingEventsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetBillingEventsResponse) GetObject() *GetBillingEventsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getconsumption.go b/internal/sdk/models/operations/getconsumption.go deleted file mode 100644 index 4fd9d1b..0000000 --- a/internal/sdk/models/operations/getconsumption.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -// Interval between consumption data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. -type Interval string - -const ( - IntervalPt15M Interval = "PT15M" - IntervalPt1H Interval = "PT1H" - IntervalP1D Interval = "P1D" - IntervalP1M Interval = "P1M" -) - -func (e Interval) ToPointer() *Interval { - return &e -} -func (e *Interval) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PT15M": - fallthrough - case "PT1H": - fallthrough - case "P1D": - fallthrough - case "P1M": - *e = Interval(v) - return nil - default: - return fmt.Errorf("invalid value for Interval: %v", v) - } -} - -type GetConsumptionRequest struct { - // Extension ID for consumption data. - ExtensionID string `queryParam:"style=form,explode=true,name=extensionId"` - // Start date for consumption data (ISO 8601 format). - From time.Time `queryParam:"style=form,explode=true,name=from"` - // Hook ID for consumption data. - HookID string `queryParam:"style=form,explode=true,name=hookId"` - // Interval between consumption data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. - Interval Interval `queryParam:"style=form,explode=true,name=interval"` - // Meter ID for consumption data. - MeterID string `queryParam:"style=form,explode=true,name=meter_id"` - // End date for consumption data (ISO 8601 format). - To time.Time `queryParam:"style=form,explode=true,name=to"` -} - -func (g GetConsumptionRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetConsumptionRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"extensionId", "from", "hookId", "interval", "meter_id", "to"}); err != nil { - return err - } - return nil -} - -func (o *GetConsumptionRequest) GetExtensionID() string { - if o == nil { - return "" - } - return o.ExtensionID -} - -func (o *GetConsumptionRequest) GetFrom() time.Time { - if o == nil { - return time.Time{} - } - return o.From -} - -func (o *GetConsumptionRequest) GetHookID() string { - if o == nil { - return "" - } - return o.HookID -} - -func (o *GetConsumptionRequest) GetInterval() Interval { - if o == nil { - return Interval("") - } - return o.Interval -} - -func (o *GetConsumptionRequest) GetMeterID() string { - if o == nil { - return "" - } - return o.MeterID -} - -func (o *GetConsumptionRequest) GetTo() time.Time { - if o == nil { - return time.Time{} - } - return o.To -} - -type Consumptions struct { - // ISO 8601 timestamp of the consumption record. - Timestamp time.Time `json:"timestamp"` - // Optional type of the consumption, such as 'nt' (night time) or 'ht' (high time). Can be any string. - Type *string `json:"type,omitempty"` - // The consumption value. - Value float64 `json:"value"` -} - -func (c Consumptions) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *Consumptions) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"timestamp", "value"}); err != nil { - return err - } - return nil -} - -func (o *Consumptions) GetTimestamp() time.Time { - if o == nil { - return time.Time{} - } - return o.Timestamp -} - -func (o *Consumptions) GetType() *string { - if o == nil { - return nil - } - return o.Type -} - -func (o *Consumptions) GetValue() float64 { - if o == nil { - return 0.0 - } - return o.Value -} - -// GetConsumptionResponseBody - Consumption data returned successfully. -type GetConsumptionResponseBody struct { - Consumptions []Consumptions `json:"consumptions,omitempty"` -} - -func (o *GetConsumptionResponseBody) GetConsumptions() []Consumptions { - if o == nil { - return nil - } - return o.Consumptions -} - -type GetConsumptionResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Consumption data returned successfully. - Object *GetConsumptionResponseBody -} - -func (o *GetConsumptionResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetConsumptionResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetConsumptionResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetConsumptionResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetConsumptionResponse) GetObject() *GetConsumptionResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getcontact.go b/internal/sdk/models/operations/getcontact.go deleted file mode 100644 index fbe5c8b..0000000 --- a/internal/sdk/models/operations/getcontact.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetContactResponseBody - Retrieves the mapped contact of the logged in user successfully. -type GetContactResponseBody struct { - // The mapped contact of the portal user - Entity *shared.Contact `json:"entity,omitempty"` - Files []shared.File `json:"files,omitempty"` - JourneyActions []shared.JourneyActions `json:"journey_actions,omitempty"` - Relations []shared.EntityItem `json:"relations,omitempty"` -} - -func (o *GetContactResponseBody) GetEntity() *shared.Contact { - if o == nil { - return nil - } - return o.Entity -} - -func (o *GetContactResponseBody) GetFiles() []shared.File { - if o == nil { - return nil - } - return o.Files -} - -func (o *GetContactResponseBody) GetJourneyActions() []shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -func (o *GetContactResponseBody) GetRelations() []shared.EntityItem { - if o == nil { - return nil - } - return o.Relations -} - -type GetContactResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieves the mapped contact of the logged in user successfully. - Object *GetContactResponseBody -} - -func (o *GetContactResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetContactResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetContactResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetContactResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetContactResponse) GetObject() *GetContactResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getcontract.go b/internal/sdk/models/operations/getcontract.go deleted file mode 100644 index 35e1f99..0000000 --- a/internal/sdk/models/operations/getcontract.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetContractRequest struct { - // The ID of the contract - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetContractRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// GetContractResponseBody - The requested contract returned successfully. -type GetContractResponseBody struct { - // The contract entity - Entity *shared.Contract `json:"entity,omitempty"` - // The related files of the requested contract - Files []shared.File `json:"files,omitempty"` - JourneyActions []shared.JourneyActions `json:"journey_actions,omitempty"` - // The related meters of the requested contract - Meters []shared.Meter `json:"meters,omitempty"` - // The related orders of the requested contract - Orders []shared.Order `json:"orders,omitempty"` - // The related entities of the requested contract - Relations []shared.EntityItem `json:"relations,omitempty"` - Workflow []map[string]any `json:"workflow,omitempty"` -} - -func (o *GetContractResponseBody) GetEntity() *shared.Contract { - if o == nil { - return nil - } - return o.Entity -} - -func (o *GetContractResponseBody) GetFiles() []shared.File { - if o == nil { - return nil - } - return o.Files -} - -func (o *GetContractResponseBody) GetJourneyActions() []shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -func (o *GetContractResponseBody) GetMeters() []shared.Meter { - if o == nil { - return nil - } - return o.Meters -} - -func (o *GetContractResponseBody) GetOrders() []shared.Order { - if o == nil { - return nil - } - return o.Orders -} - -func (o *GetContractResponseBody) GetRelations() []shared.EntityItem { - if o == nil { - return nil - } - return o.Relations -} - -func (o *GetContractResponseBody) GetWorkflow() []map[string]any { - if o == nil { - return nil - } - return o.Workflow -} - -type GetContractResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The requested contract returned successfully. - Object *GetContractResponseBody -} - -func (o *GetContractResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetContractResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetContractResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetContractResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetContractResponse) GetObject() *GetContractResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getcosts.go b/internal/sdk/models/operations/getcosts.go deleted file mode 100644 index 572b786..0000000 --- a/internal/sdk/models/operations/getcosts.go +++ /dev/null @@ -1,268 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -// QueryParamInterval - Interval between cost data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. -type QueryParamInterval string - -const ( - QueryParamIntervalPt15M QueryParamInterval = "PT15M" - QueryParamIntervalPt1H QueryParamInterval = "PT1H" - QueryParamIntervalP1D QueryParamInterval = "P1D" - QueryParamIntervalP1M QueryParamInterval = "P1M" -) - -func (e QueryParamInterval) ToPointer() *QueryParamInterval { - return &e -} -func (e *QueryParamInterval) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PT15M": - fallthrough - case "PT1H": - fallthrough - case "P1D": - fallthrough - case "P1M": - *e = QueryParamInterval(v) - return nil - default: - return fmt.Errorf("invalid value for QueryParamInterval: %v", v) - } -} - -type GetCostsRequest struct { - // Extension ID for cost data. - ExtensionID string `queryParam:"style=form,explode=true,name=extensionId"` - // Start date for cost data (ISO 8601 format). - From time.Time `queryParam:"style=form,explode=true,name=from"` - // Hook ID for cost data. - HookID string `queryParam:"style=form,explode=true,name=hookId"` - // Interval between cost data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. - Interval QueryParamInterval `queryParam:"style=form,explode=true,name=interval"` - // Meter ID for cost data. - MeterID string `queryParam:"style=form,explode=true,name=meter_id"` - // End date for cost data (ISO 8601 format). - To time.Time `queryParam:"style=form,explode=true,name=to"` -} - -func (g GetCostsRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetCostsRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"extensionId", "from", "hookId", "interval", "meter_id", "to"}); err != nil { - return err - } - return nil -} - -func (o *GetCostsRequest) GetExtensionID() string { - if o == nil { - return "" - } - return o.ExtensionID -} - -func (o *GetCostsRequest) GetFrom() time.Time { - if o == nil { - return time.Time{} - } - return o.From -} - -func (o *GetCostsRequest) GetHookID() string { - if o == nil { - return "" - } - return o.HookID -} - -func (o *GetCostsRequest) GetInterval() QueryParamInterval { - if o == nil { - return QueryParamInterval("") - } - return o.Interval -} - -func (o *GetCostsRequest) GetMeterID() string { - if o == nil { - return "" - } - return o.MeterID -} - -func (o *GetCostsRequest) GetTo() time.Time { - if o == nil { - return time.Time{} - } - return o.To -} - -// TaxBehavior - Is the tax (typically Value Added Tax) included in the amounts. Typically should NOT be included - exclusive of tax. -type TaxBehavior string - -const ( - TaxBehaviorInclusive TaxBehavior = "inclusive" - TaxBehaviorExclusive TaxBehavior = "exclusive" -) - -func (e TaxBehavior) ToPointer() *TaxBehavior { - return &e -} -func (e *TaxBehavior) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "inclusive": - fallthrough - case "exclusive": - *e = TaxBehavior(v) - return nil - default: - return fmt.Errorf("invalid value for TaxBehavior: %v", v) - } -} - -type Costs struct { - // Is the tax (typically Value Added Tax) included in the amounts. Typically should NOT be included - exclusive of tax. - TaxBehavior TaxBehavior `json:"tax_behavior"` - // Tax rate in percent, e.g. 19 for 19%. - TaxRate int64 `json:"tax_rate"` - // ISO 8601 timestamp of the cost record. - Timestamp time.Time `json:"timestamp"` - // Cost in cents, e.g. 1234 for 12,34 €. - UnitAmount int64 `json:"unit_amount"` - // ISO 4217:2015 currency. - UnitAmountCurrency string `json:"unit_amount_currency"` - // Cost in decimal format, e.g. "12.34". - UnitAmountDecimal string `json:"unit_amount_decimal"` -} - -func (c Costs) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *Costs) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"tax_behavior", "tax_rate", "timestamp", "unit_amount", "unit_amount_currency", "unit_amount_decimal"}); err != nil { - return err - } - return nil -} - -func (o *Costs) GetTaxBehavior() TaxBehavior { - if o == nil { - return TaxBehavior("") - } - return o.TaxBehavior -} - -func (o *Costs) GetTaxRate() int64 { - if o == nil { - return 0 - } - return o.TaxRate -} - -func (o *Costs) GetTimestamp() time.Time { - if o == nil { - return time.Time{} - } - return o.Timestamp -} - -func (o *Costs) GetUnitAmount() int64 { - if o == nil { - return 0 - } - return o.UnitAmount -} - -func (o *Costs) GetUnitAmountCurrency() string { - if o == nil { - return "" - } - return o.UnitAmountCurrency -} - -func (o *Costs) GetUnitAmountDecimal() string { - if o == nil { - return "" - } - return o.UnitAmountDecimal -} - -// GetCostsResponseBody - Cost data returned successfully. -type GetCostsResponseBody struct { - Costs []Costs `json:"costs,omitempty"` -} - -func (o *GetCostsResponseBody) GetCosts() []Costs { - if o == nil { - return nil - } - return o.Costs -} - -type GetCostsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Cost data returned successfully. - Object *GetCostsResponseBody -} - -func (o *GetCostsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetCostsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetCostsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetCostsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetCostsResponse) GetObject() *GetCostsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getdefaultpages.go b/internal/sdk/models/operations/getdefaultpages.go deleted file mode 100644 index b3eb649..0000000 --- a/internal/sdk/models/operations/getdefaultpages.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetDefaultPagesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The default portal pages have been fetched successfully. - Classes []shared.Page -} - -func (o *GetDefaultPagesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetDefaultPagesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetDefaultPagesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetDefaultPagesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetDefaultPagesResponse) GetClasses() []shared.Page { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getecpcontact.go b/internal/sdk/models/operations/getecpcontact.go deleted file mode 100644 index b19af8b..0000000 --- a/internal/sdk/models/operations/getecpcontact.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetECPContactRequest struct { - ID string `queryParam:"style=form,explode=true,name=id"` -} - -func (o *GetECPContactRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// GetECPContactResponseBody - The contact returned successfully. -type GetECPContactResponseBody struct { - // The mapped contact of the portal user - Data *shared.Contact `json:"data,omitempty"` -} - -func (o *GetECPContactResponseBody) GetData() *shared.Contact { - if o == nil { - return nil - } - return o.Data -} - -type GetECPContactResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The contact returned successfully. - Object *GetECPContactResponseBody -} - -func (o *GetECPContactResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetECPContactResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetECPContactResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetECPContactResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetECPContactResponse) GetObject() *GetECPContactResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getemailtemplates.go b/internal/sdk/models/operations/getemailtemplates.go deleted file mode 100644 index 1c10e2e..0000000 --- a/internal/sdk/models/operations/getemailtemplates.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetEmailTemplatesRequest struct { - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetEmailTemplatesRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type GetEmailTemplatesResponse struct { - // HTTP response content type for this operation - ContentType string - // Retrieved the email templates successfully. - EmailTemplates *shared.EmailTemplates - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetEmailTemplatesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetEmailTemplatesResponse) GetEmailTemplates() *shared.EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *GetEmailTemplatesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetEmailTemplatesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetEmailTemplatesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getentityactivityfeed.go b/internal/sdk/models/operations/getentityactivityfeed.go deleted file mode 100644 index 07c27f0..0000000 --- a/internal/sdk/models/operations/getentityactivityfeed.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -type GetEntityActivityFeedRequest struct { - // Get activities after this timestamp - After *time.Time `queryParam:"style=form,explode=true,name=after"` - // get activities before this timestamp - Before *time.Time `queryParam:"style=form,explode=true,name=before"` - // start from page - From *int64 `default:"0" queryParam:"style=form,explode=true,name=from"` - // Entity id - ID string `pathParam:"style=simple,explode=false,name=id"` - // Include activities from related entities - IncludeRelations *bool `default:"false" queryParam:"style=form,explode=true,name=include_relations"` - // max number of results to return - Size *int64 `default:"25" queryParam:"style=form,explode=true,name=size"` - // Entity Type - Slug shared.EntitySlug `pathParam:"style=simple,explode=false,name=slug"` - // Filter by activity type - Type *string `queryParam:"style=form,explode=true,name=type"` -} - -func (g GetEntityActivityFeedRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetEntityActivityFeedRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"id", "slug"}); err != nil { - return err - } - return nil -} - -func (o *GetEntityActivityFeedRequest) GetAfter() *time.Time { - if o == nil { - return nil - } - return o.After -} - -func (o *GetEntityActivityFeedRequest) GetBefore() *time.Time { - if o == nil { - return nil - } - return o.Before -} - -func (o *GetEntityActivityFeedRequest) GetFrom() *int64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetEntityActivityFeedRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *GetEntityActivityFeedRequest) GetIncludeRelations() *bool { - if o == nil { - return nil - } - return o.IncludeRelations -} - -func (o *GetEntityActivityFeedRequest) GetSize() *int64 { - if o == nil { - return nil - } - return o.Size -} - -func (o *GetEntityActivityFeedRequest) GetSlug() shared.EntitySlug { - if o == nil { - return shared.EntitySlug("") - } - return o.Slug -} - -func (o *GetEntityActivityFeedRequest) GetType() *string { - if o == nil { - return nil - } - return o.Type -} - -// GetEntityActivityFeedResponseBody - Success -type GetEntityActivityFeedResponseBody struct { - Results []shared.ActivityItem `json:"results,omitempty"` - Total *int64 `json:"total,omitempty"` -} - -func (o *GetEntityActivityFeedResponseBody) GetResults() []shared.ActivityItem { - if o == nil { - return nil - } - return o.Results -} - -func (o *GetEntityActivityFeedResponseBody) GetTotal() *int64 { - if o == nil { - return nil - } - return o.Total -} - -type GetEntityActivityFeedResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Success - Object *GetEntityActivityFeedResponseBody -} - -func (o *GetEntityActivityFeedResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetEntityActivityFeedResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetEntityActivityFeedResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetEntityActivityFeedResponse) GetObject() *GetEntityActivityFeedResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getentityidentifiers.go b/internal/sdk/models/operations/getentityidentifiers.go deleted file mode 100644 index f1cb13d..0000000 --- a/internal/sdk/models/operations/getentityidentifiers.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetEntityIdentifiersRequest struct { - // The slug of an entity - Slug shared.EntitySlug `pathParam:"style=simple,explode=false,name=slug"` -} - -func (o *GetEntityIdentifiersRequest) GetSlug() shared.EntitySlug { - if o == nil { - return shared.EntitySlug("") - } - return o.Slug -} - -type GetEntityIdentifiersData struct { - // The name of the identifier - Name *string `json:"name,omitempty"` - // The type of the identifier - Type *string `json:"type,omitempty"` -} - -func (o *GetEntityIdentifiersData) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *GetEntityIdentifiersData) GetType() *string { - if o == nil { - return nil - } - return o.Type -} - -// GetEntityIdentifiersResponseBody - The identifiers of the requested entity returned successfully. -type GetEntityIdentifiersResponseBody struct { - Data []GetEntityIdentifiersData `json:"data,omitempty"` -} - -func (o *GetEntityIdentifiersResponseBody) GetData() []GetEntityIdentifiersData { - if o == nil { - return nil - } - return o.Data -} - -type GetEntityIdentifiersResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The identifiers of the requested entity returned successfully. - Object *GetEntityIdentifiersResponseBody -} - -func (o *GetEntityIdentifiersResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetEntityIdentifiersResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetEntityIdentifiersResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetEntityIdentifiersResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetEntityIdentifiersResponse) GetObject() *GetEntityIdentifiersResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getexternallinks.go b/internal/sdk/models/operations/getexternallinks.go deleted file mode 100644 index bb0a08b..0000000 --- a/internal/sdk/models/operations/getexternallinks.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetExternalLinksRequest struct { - // Contact ID of the user - ContactID *string `queryParam:"style=form,explode=true,name=contactId"` - // Origin of the portal - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetExternalLinksRequest) GetContactID() *string { - if o == nil { - return nil - } - return o.ContactID -} - -func (o *GetExternalLinksRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -type GetExternalLinksResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal config links retrieved successfully. - Classes []shared.ExternalLink -} - -func (o *GetExternalLinksResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetExternalLinksResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetExternalLinksResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetExternalLinksResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetExternalLinksResponse) GetClasses() []shared.ExternalLink { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getfilebyid.go b/internal/sdk/models/operations/getfilebyid.go deleted file mode 100644 index f6aad25..0000000 --- a/internal/sdk/models/operations/getfilebyid.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetFileByIDRequest struct { - // The Id of a file - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetFileByIDRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// GetFileByIDResponseBody - The files have been fetched successfully. -type GetFileByIDResponseBody struct { - File *shared.FileItem `json:"file,omitempty"` -} - -func (o *GetFileByIDResponseBody) GetFile() *shared.FileItem { - if o == nil { - return nil - } - return o.File -} - -type GetFileByIDResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The files have been fetched successfully. - Object *GetFileByIDResponseBody -} - -func (o *GetFileByIDResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetFileByIDResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetFileByIDResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetFileByIDResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetFileByIDResponse) GetObject() *GetFileByIDResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getfilescountbyentity.go b/internal/sdk/models/operations/getfilescountbyentity.go deleted file mode 100644 index 9d73d83..0000000 --- a/internal/sdk/models/operations/getfilescountbyentity.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetFilesCountByEntityResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The file counts have been fetched successfully. - Classes []shared.EntityFileCount -} - -func (o *GetFilesCountByEntityResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetFilesCountByEntityResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetFilesCountByEntityResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetFilesCountByEntityResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetFilesCountByEntityResponse) GetClasses() []shared.EntityFileCount { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getjuicesettings.go b/internal/sdk/models/operations/getjuicesettings.go deleted file mode 100644 index 9ea9d05..0000000 --- a/internal/sdk/models/operations/getjuicesettings.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetJuiceSettingsRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *GetJuiceSettingsRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -type GetJuiceSettingsResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // Juice settings retrieved successfully. - JuiceSettings *shared.JuiceSettings - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetJuiceSettingsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetJuiceSettingsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetJuiceSettingsResponse) GetJuiceSettings() *shared.JuiceSettings { - if o == nil { - return nil - } - return o.JuiceSettings -} - -func (o *GetJuiceSettingsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetJuiceSettingsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getopportunity.go b/internal/sdk/models/operations/getopportunity.go deleted file mode 100644 index ecad523..0000000 --- a/internal/sdk/models/operations/getopportunity.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetOpportunityRequest struct { - // The ID of opportunity - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetOpportunityRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// GetOpportunityResponseBody - The returned opportunities -type GetOpportunityResponseBody struct { - // The opportunity entity - Entity *shared.Opportunity `json:"entity,omitempty"` - // The related files of the requested opportunity - Files []shared.File `json:"files,omitempty"` - JourneyActions []shared.JourneyActions `json:"journey_actions,omitempty"` - // The related orders of the requested opportunity - Orders []shared.Order `json:"orders,omitempty"` - // The related entities of the requested opportunity - Relations []shared.EntityItem `json:"relations,omitempty"` - // The related workflows of the requested opportunity - Workflow []map[string]any `json:"workflow,omitempty"` -} - -func (o *GetOpportunityResponseBody) GetEntity() *shared.Opportunity { - if o == nil { - return nil - } - return o.Entity -} - -func (o *GetOpportunityResponseBody) GetFiles() []shared.File { - if o == nil { - return nil - } - return o.Files -} - -func (o *GetOpportunityResponseBody) GetJourneyActions() []shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -func (o *GetOpportunityResponseBody) GetOrders() []shared.Order { - if o == nil { - return nil - } - return o.Orders -} - -func (o *GetOpportunityResponseBody) GetRelations() []shared.EntityItem { - if o == nil { - return nil - } - return o.Relations -} - -func (o *GetOpportunityResponseBody) GetWorkflow() []map[string]any { - if o == nil { - return nil - } - return o.Workflow -} - -type GetOpportunityResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The returned opportunities - Object *GetOpportunityResponseBody -} - -func (o *GetOpportunityResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetOpportunityResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetOpportunityResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetOpportunityResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetOpportunityResponse) GetObject() *GetOpportunityResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getorder.go b/internal/sdk/models/operations/getorder.go deleted file mode 100644 index ba6a1d0..0000000 --- a/internal/sdk/models/operations/getorder.go +++ /dev/null @@ -1,134 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetOrderRequest struct { - // The ID of order - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetOrderRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// GetOrderResponseBody - The requested order has been retrieved successfully. -type GetOrderResponseBody struct { - // The related cross sellable products of the requested order - CrossSellableProducts []shared.Product `json:"crossSellableProducts,omitempty"` - // The order entity - Entity *shared.Order `json:"entity,omitempty"` - // The related files of the requested order - Files []shared.File `json:"files,omitempty"` - JourneyActions []shared.JourneyActions `json:"journey_actions,omitempty"` - // The related products of the requested order - Products []shared.Product `json:"products,omitempty"` - // The related entities of the requested order - Relations []shared.EntityItem `json:"relations,omitempty"` - // The related workflows of the requested order - Workflow []map[string]any `json:"workflow,omitempty"` -} - -func (o *GetOrderResponseBody) GetCrossSellableProducts() []shared.Product { - if o == nil { - return nil - } - return o.CrossSellableProducts -} - -func (o *GetOrderResponseBody) GetEntity() *shared.Order { - if o == nil { - return nil - } - return o.Entity -} - -func (o *GetOrderResponseBody) GetFiles() []shared.File { - if o == nil { - return nil - } - return o.Files -} - -func (o *GetOrderResponseBody) GetJourneyActions() []shared.JourneyActions { - if o == nil { - return nil - } - return o.JourneyActions -} - -func (o *GetOrderResponseBody) GetProducts() []shared.Product { - if o == nil { - return nil - } - return o.Products -} - -func (o *GetOrderResponseBody) GetRelations() []shared.EntityItem { - if o == nil { - return nil - } - return o.Relations -} - -func (o *GetOrderResponseBody) GetWorkflow() []map[string]any { - if o == nil { - return nil - } - return o.Workflow -} - -type GetOrderResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The requested order has been retrieved successfully. - Object *GetOrderResponseBody -} - -func (o *GetOrderResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetOrderResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetOrderResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetOrderResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetOrderResponse) GetObject() *GetOrderResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getorganizationsettings.go b/internal/sdk/models/operations/getorganizationsettings.go deleted file mode 100644 index 9727eae..0000000 --- a/internal/sdk/models/operations/getorganizationsettings.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetOrganizationSettingsResponseBody - Retrieved the settings for an organization successfully. -type GetOrganizationSettingsResponseBody struct { - Data *shared.OrganizationSettings `json:"data,omitempty"` -} - -func (o *GetOrganizationSettingsResponseBody) GetData() *shared.OrganizationSettings { - if o == nil { - return nil - } - return o.Data -} - -type GetOrganizationSettingsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved the settings for an organization successfully. - Object *GetOrganizationSettingsResponseBody -} - -func (o *GetOrganizationSettingsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetOrganizationSettingsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetOrganizationSettingsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetOrganizationSettingsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetOrganizationSettingsResponse) GetObject() *GetOrganizationSettingsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getorganizationsettingsbydomain.go b/internal/sdk/models/operations/getorganizationsettingsbydomain.go deleted file mode 100644 index aa61a24..0000000 --- a/internal/sdk/models/operations/getorganizationsettingsbydomain.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetOrganizationSettingsByDomainRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *GetOrganizationSettingsByDomainRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -// GetOrganizationSettingsByDomainResponseBody - Retrieved organization settings successfully. -type GetOrganizationSettingsByDomainResponseBody struct { - Data *shared.OrganizationSettings `json:"data,omitempty"` -} - -func (o *GetOrganizationSettingsByDomainResponseBody) GetData() *shared.OrganizationSettings { - if o == nil { - return nil - } - return o.Data -} - -type GetOrganizationSettingsByDomainResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved organization settings successfully. - Object *GetOrganizationSettingsByDomainResponseBody -} - -func (o *GetOrganizationSettingsByDomainResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetOrganizationSettingsByDomainResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetOrganizationSettingsByDomainResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetOrganizationSettingsByDomainResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetOrganizationSettingsByDomainResponse) GetObject() *GetOrganizationSettingsByDomainResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getorgportalconfig.go b/internal/sdk/models/operations/getorgportalconfig.go deleted file mode 100644 index e65a277..0000000 --- a/internal/sdk/models/operations/getorgportalconfig.go +++ /dev/null @@ -1,1066 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetOrgPortalConfigRequest struct { - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetOrgPortalConfigRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type AdvancedMfa struct { - // Advanced MFA feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *AdvancedMfa) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type GetOrgPortalConfigEntryPoint string - -const ( - GetOrgPortalConfigEntryPointPassword GetOrgPortalConfigEntryPoint = "PASSWORD" - GetOrgPortalConfigEntryPointSso GetOrgPortalConfigEntryPoint = "SSO" -) - -func (e GetOrgPortalConfigEntryPoint) ToPointer() *GetOrgPortalConfigEntryPoint { - return &e -} -func (e *GetOrgPortalConfigEntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = GetOrgPortalConfigEntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for GetOrgPortalConfigEntryPoint: %v", v) - } -} - -type PasswordlessLogin struct { - // Passwordless login feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PasswordlessLogin) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// AuthSettings - Authentication settings for the portal -type AuthSettings struct { - // Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. - AutoRedirectToSso *bool `json:"auto_redirect_to_sso,omitempty"` - EntryPoint *GetOrgPortalConfigEntryPoint `json:"entry_point,omitempty"` - PasswordlessLogin *PasswordlessLogin `json:"passwordless_login,omitempty"` - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` -} - -func (o *AuthSettings) GetAutoRedirectToSso() *bool { - if o == nil { - return nil - } - return o.AutoRedirectToSso -} - -func (o *AuthSettings) GetEntryPoint() *GetOrgPortalConfigEntryPoint { - if o == nil { - return nil - } - return o.EntryPoint -} - -func (o *AuthSettings) GetPasswordlessLogin() *PasswordlessLogin { - if o == nil { - return nil - } - return o.PasswordlessLogin -} - -func (o *AuthSettings) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -// GetOrgPortalConfigStatus - Status of the certificate -type GetOrgPortalConfigStatus string - -const ( - GetOrgPortalConfigStatusPendingValidation GetOrgPortalConfigStatus = "PENDING_VALIDATION" - GetOrgPortalConfigStatusIssued GetOrgPortalConfigStatus = "ISSUED" - GetOrgPortalConfigStatusInactive GetOrgPortalConfigStatus = "INACTIVE" - GetOrgPortalConfigStatusExpired GetOrgPortalConfigStatus = "EXPIRED" - GetOrgPortalConfigStatusValidationTimedOut GetOrgPortalConfigStatus = "VALIDATION_TIMED_OUT" - GetOrgPortalConfigStatusRevoked GetOrgPortalConfigStatus = "REVOKED" - GetOrgPortalConfigStatusFailed GetOrgPortalConfigStatus = "FAILED" - GetOrgPortalConfigStatusPendingAutoRenewal GetOrgPortalConfigStatus = "PENDING_AUTO_RENEWAL" -) - -func (e GetOrgPortalConfigStatus) ToPointer() *GetOrgPortalConfigStatus { - return &e -} -func (e *GetOrgPortalConfigStatus) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PENDING_VALIDATION": - fallthrough - case "ISSUED": - fallthrough - case "INACTIVE": - fallthrough - case "EXPIRED": - fallthrough - case "VALIDATION_TIMED_OUT": - fallthrough - case "REVOKED": - fallthrough - case "FAILED": - fallthrough - case "PENDING_AUTO_RENEWAL": - *e = GetOrgPortalConfigStatus(v) - return nil - default: - return fmt.Errorf("invalid value for GetOrgPortalConfigStatus: %v", v) - } -} - -type CertificateDetails struct { - // Reason for failed certificate - FailedReason *string `json:"failed_reason,omitempty"` - // Status of the certificate - Status *GetOrgPortalConfigStatus `json:"status,omitempty"` -} - -func (o *CertificateDetails) GetFailedReason() *string { - if o == nil { - return nil - } - return o.FailedReason -} - -func (o *CertificateDetails) GetStatus() *GetOrgPortalConfigStatus { - if o == nil { - return nil - } - return o.Status -} - -// PasswordPolicy - Password policy for the portal -type PasswordPolicy struct { - // Minimum password length - MinimumLength *int64 `json:"minimum_length,omitempty"` - // Require lowercase characters - RequireLowercase *bool `json:"require_lowercase,omitempty"` - // Require numbers - RequireNumbers *bool `json:"require_numbers,omitempty"` - // Require symbols - RequireSymbols *bool `json:"require_symbols,omitempty"` - // Require uppercase characters - RequireUppercase *bool `json:"require_uppercase,omitempty"` -} - -func (o *PasswordPolicy) GetMinimumLength() *int64 { - if o == nil { - return nil - } - return o.MinimumLength -} - -func (o *PasswordPolicy) GetRequireLowercase() *bool { - if o == nil { - return nil - } - return o.RequireLowercase -} - -func (o *PasswordPolicy) GetRequireNumbers() *bool { - if o == nil { - return nil - } - return o.RequireNumbers -} - -func (o *PasswordPolicy) GetRequireSymbols() *bool { - if o == nil { - return nil - } - return o.RequireSymbols -} - -func (o *PasswordPolicy) GetRequireUppercase() *bool { - if o == nil { - return nil - } - return o.RequireUppercase -} - -// CognitoDetails - AWS Cognito Pool details for the portal -type CognitoDetails struct { - // Cognito user pool ARN - CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` - // Cognito user pool client ID - CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` - // Cognito user pool ID - CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` - // Password policy for the portal - PasswordPolicy *PasswordPolicy `json:"password_policy,omitempty"` -} - -func (o *CognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolArn -} - -func (o *CognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolClientID -} - -func (o *CognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolID -} - -func (o *CognitoDetails) GetPasswordPolicy() *PasswordPolicy { - if o == nil { - return nil - } - return o.PasswordPolicy -} - -// ContractSelectorConfig - Configuration for contract selector in the portal -type ContractSelectorConfig struct { - // Whether to show inactive contracts in the selector - ShowInactive *bool `json:"show_inactive,omitempty"` - // Path to the property to use as the contract title - TitlePath *string `json:"title_path,omitempty"` -} - -func (o *ContractSelectorConfig) GetShowInactive() *bool { - if o == nil { - return nil - } - return o.ShowInactive -} - -func (o *ContractSelectorConfig) GetTitlePath() *string { - if o == nil { - return nil - } - return o.TitlePath -} - -type CadencePeriodType string - -const ( - CadencePeriodTypeDays CadencePeriodType = "days" - CadencePeriodTypeWeeks CadencePeriodType = "weeks" - CadencePeriodTypeMonths CadencePeriodType = "months" -) - -func (e CadencePeriodType) ToPointer() *CadencePeriodType { - return &e -} -func (e *CadencePeriodType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "days": - fallthrough - case "weeks": - fallthrough - case "months": - *e = CadencePeriodType(v) - return nil - default: - return fmt.Errorf("invalid value for CadencePeriodType: %v", v) - } -} - -type RuleType string - -const ( - RuleTypeCadence RuleType = "cadence" - RuleTypeRelativeToCurrentValue RuleType = "relative_to_current_value" - RuleTypeDaysBeforeDate RuleType = "days_before_date" - RuleTypeOverduePayments RuleType = "overdue_payments" -) - -func (e RuleType) ToPointer() *RuleType { - return &e -} -func (e *RuleType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "cadence": - fallthrough - case "relative_to_current_value": - fallthrough - case "days_before_date": - fallthrough - case "overdue_payments": - *e = RuleType(v) - return nil - default: - return fmt.Errorf("invalid value for RuleType: %v", v) - } -} - -type EntityEditRules struct { - AllowedDecrement *string `json:"allowed_decrement,omitempty"` - AllowedIncrement *string `json:"allowed_increment,omitempty"` - Attribute *string `json:"attribute,omitempty"` - CadencePeriod *float64 `json:"cadence_period,omitempty"` - CadencePeriodType *CadencePeriodType `json:"cadence_period_type,omitempty"` - ChangesAllowed *int64 `json:"changes_allowed,omitempty"` - GracePeriod *int64 `json:"grace_period,omitempty"` - NumberOfDaysBeforeRestriction *int64 `json:"number_of_days_before_restriction,omitempty"` - RuleType *RuleType `json:"rule_type,omitempty"` - // URL-friendly identifier for the entity schema - Slug *shared.EntitySlug `json:"slug,omitempty"` -} - -func (o *EntityEditRules) GetAllowedDecrement() *string { - if o == nil { - return nil - } - return o.AllowedDecrement -} - -func (o *EntityEditRules) GetAllowedIncrement() *string { - if o == nil { - return nil - } - return o.AllowedIncrement -} - -func (o *EntityEditRules) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *EntityEditRules) GetCadencePeriod() *float64 { - if o == nil { - return nil - } - return o.CadencePeriod -} - -func (o *EntityEditRules) GetCadencePeriodType() *CadencePeriodType { - if o == nil { - return nil - } - return o.CadencePeriodType -} - -func (o *EntityEditRules) GetChangesAllowed() *int64 { - if o == nil { - return nil - } - return o.ChangesAllowed -} - -func (o *EntityEditRules) GetGracePeriod() *int64 { - if o == nil { - return nil - } - return o.GracePeriod -} - -func (o *EntityEditRules) GetNumberOfDaysBeforeRestriction() *int64 { - if o == nil { - return nil - } - return o.NumberOfDaysBeforeRestriction -} - -func (o *EntityEditRules) GetRuleType() *RuleType { - if o == nil { - return nil - } - return o.RuleType -} - -func (o *EntityEditRules) GetSlug() *shared.EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type GetOrgPortalConfigType struct { - // Attributes used to identify an entity - Attributes []string `json:"attributes,omitempty"` - // Enable/Disable the entity identifier - IsEnabled *bool `json:"isEnabled,omitempty"` -} - -func (o *GetOrgPortalConfigType) GetAttributes() []string { - if o == nil { - return nil - } - return o.Attributes -} - -func (o *GetOrgPortalConfigType) GetIsEnabled() *bool { - if o == nil { - return nil - } - return o.IsEnabled -} - -// EntityIdentifiers - Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type EntityIdentifiers struct { - Type *GetOrgPortalConfigType `json:"type,omitempty"` -} - -func (o *EntityIdentifiers) GetType() *GetOrgPortalConfigType { - if o == nil { - return nil - } - return o.Type -} - -// FeatureSettings - Feature settings for the portal -type FeatureSettings struct { - // Billing feature flag - Billing *bool `json:"billing,omitempty"` - // Change due date feature flag - ChangeDueDate *bool `json:"change_due_date,omitempty"` - // Enable or disable the new design for the portal - NewDesign *bool `json:"new_design,omitempty"` - // Start page feature flag - StartPage *bool `json:"start_page,omitempty"` -} - -func (o *FeatureSettings) GetBilling() *bool { - if o == nil { - return nil - } - return o.Billing -} - -func (o *FeatureSettings) GetChangeDueDate() *bool { - if o == nil { - return nil - } - return o.ChangeDueDate -} - -func (o *FeatureSettings) GetNewDesign() *bool { - if o == nil { - return nil - } - return o.NewDesign -} - -func (o *FeatureSettings) GetStartPage() *bool { - if o == nil { - return nil - } - return o.StartPage -} - -// Images - Teaser & Banner Image web links -type Images struct { - // URL of the order left teaser image - OrderLeftTeaser *string `json:"orderLeftTeaser,omitempty"` - // URL of the order right teaser image - OrderRightTeaser *string `json:"orderRightTeaser,omitempty"` - // URL of the welcome banner image - WelcomeBanner *string `json:"welcomeBanner,omitempty"` -} - -func (o *Images) GetOrderLeftTeaser() *string { - if o == nil { - return nil - } - return o.OrderLeftTeaser -} - -func (o *Images) GetOrderRightTeaser() *string { - if o == nil { - return nil - } - return o.OrderRightTeaser -} - -func (o *Images) GetWelcomeBanner() *string { - if o == nil { - return nil - } - return o.WelcomeBanner -} - -// Canary feature flag -type Canary struct { - // Enable/Disable the canary feature - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Canary) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// Notracking - Disable Advanced Usage Metrics -type Notracking struct { - // Disable browser-side scripts that track advanced usage metrics - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Notracking) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// OrgSettings - Organization settings -type OrgSettings struct { - // Canary feature flag - Canary *Canary `json:"canary,omitempty"` - // Disable Advanced Usage Metrics - Notracking *Notracking `json:"notracking,omitempty"` -} - -func (o *OrgSettings) GetCanary() *Canary { - if o == nil { - return nil - } - return o.Canary -} - -func (o *OrgSettings) GetNotracking() *Notracking { - if o == nil { - return nil - } - return o.Notracking -} - -type SelfRegistrationSetting string - -const ( - SelfRegistrationSettingAllowWithContactCreation SelfRegistrationSetting = "ALLOW_WITH_CONTACT_CREATION" - SelfRegistrationSettingAllowWithoutContactCreation SelfRegistrationSetting = "ALLOW_WITHOUT_CONTACT_CREATION" - SelfRegistrationSettingDeny SelfRegistrationSetting = "DENY" -) - -func (e SelfRegistrationSetting) ToPointer() *SelfRegistrationSetting { - return &e -} -func (e *SelfRegistrationSetting) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ALLOW_WITH_CONTACT_CREATION": - fallthrough - case "ALLOW_WITHOUT_CONTACT_CREATION": - fallthrough - case "DENY": - *e = SelfRegistrationSetting(v) - return nil - default: - return fmt.Errorf("invalid value for SelfRegistrationSetting: %v", v) - } -} - -type TriggerName string - -const ( - TriggerNameFirstLogin TriggerName = "FIRST_LOGIN" - TriggerNameAcceptOrder TriggerName = "ACCEPT_ORDER" - TriggerNameDeclineOrder TriggerName = "DECLINE_ORDER" -) - -func (e TriggerName) ToPointer() *TriggerName { - return &e -} -func (e *TriggerName) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "FIRST_LOGIN": - fallthrough - case "ACCEPT_ORDER": - fallthrough - case "DECLINE_ORDER": - *e = TriggerName(v) - return nil - default: - return fmt.Errorf("invalid value for TriggerName: %v", v) - } -} - -type TriggeredJourneys struct { - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - TriggerName *TriggerName `json:"trigger_name,omitempty"` -} - -func (o *TriggeredJourneys) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *TriggeredJourneys) GetTriggerName() *TriggerName { - if o == nil { - return nil - } - return o.TriggerName -} - -// GetOrgPortalConfigResponseBody - Portal config retrieved successfully. -type GetOrgPortalConfigResponseBody struct { - // Access token for the portal - AccessToken *string `json:"accessToken,omitempty"` - AdvancedMfa *AdvancedMfa `json:"advanced_mfa,omitempty"` - // Allowed file extensions for upload - AllowedFileExtensions *shared.AllowedFileExtensions `json:"allowed_file_extensions,omitempty"` - ApprovalStateAttributes map[string][]string `json:"approval_state_attributes,omitempty"` - // Authentication settings for the portal - AuthSettings *AuthSettings `json:"auth_settings,omitempty"` - CertificateDetails *CertificateDetails `json:"certificate_details,omitempty"` - // AWS Cognito Pool details for the portal - CognitoDetails *CognitoDetails `json:"cognito_details,omitempty"` - // Stringified object with configuration details - Config *string `json:"config,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers []string `json:"contact_identifiers,omitempty"` - // Identifiers to identify a contract by a portal user. - ContractIdentifiers []shared.ContractIdentifier `json:"contract_identifiers,omitempty"` - // Configuration for contract selector in the portal - ContractSelectorConfig *ContractSelectorConfig `json:"contract_selector_config,omitempty"` - // Entity ID - DesignID *string `json:"design_id,omitempty"` - // The URL on which the portal is accessible - Domain string `json:"domain"` - // Email templates used for authentication and internal processes - EmailTemplates *shared.EmailTemplates `json:"email_templates,omitempty"` - // Enable/Disable the portal access - Enabled *bool `json:"enabled,omitempty"` - // Rules for editing an entity by a portal user - EntityEditRules []EntityEditRules `json:"entity_edit_rules,omitempty"` - // Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - EntityIdentifiers *EntityIdentifiers `json:"entity_identifiers,omitempty"` - // Feature flags for the portal - FeatureFlags map[string]bool `json:"feature_flags,omitempty"` - // Feature settings for the portal - FeatureSettings *FeatureSettings `json:"feature_settings,omitempty"` - // Permissions granted to a portal user while accessing entities - Grants []shared.Grant `json:"grants,omitempty"` - // ID of the organization - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ID *string `json:"id,omitempty"` - IdentityProviders []shared.ProviderPublicConfig `json:"identity_providers,omitempty"` - // Teaser & Banner Image web links - Images *Images `json:"images,omitempty"` - // Number of years to look back for showing inactive contracts in the portal - InactiveContractCutoffYears *float64 `json:"inactive_contract_cutoff_years,omitempty"` - // Whether this is a dummy/test portal configuration - IsDummy *bool `json:"is_dummy,omitempty"` - // Mark true if the domain is an Epilot domain - IsEpilotDomain *bool `json:"is_epilot_domain,omitempty"` - // Whether this is a v3 portal configuration - IsV3Item *bool `json:"is_v3_item,omitempty"` - // Grace period in days for meter readings - MeterReadingGracePeriod *float64 `json:"meter_reading_grace_period,omitempty"` - // A short name to identify your portal - Name *string `json:"name,omitempty"` - // Organization settings - OrgSettings *OrgSettings `json:"org_settings,omitempty"` - // ID of the organization - OrganizationID *string `json:"organization_id,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` - Pages map[string]shared.Page `json:"pages,omitempty"` - // ID of the portal - PortalID *string `json:"portal_id,omitempty"` - // Key of the portal config - PortalSkV3 *string `json:"portal_sk_v3,omitempty"` - // Prevent indexing by search engines - PreventSearchEngineIndexing *bool `json:"prevent_search_engine_indexing,omitempty"` - // Identifiers to identify a contact of a portal user during the registration. - RegistrationIdentifiers []shared.ContractIdentifier `json:"registration_identifiers,omitempty"` - SelfRegistrationSetting *SelfRegistrationSetting `json:"self_registration_setting,omitempty"` - // Journeys automatically opened on a portal user action - TriggeredJourneys []TriggeredJourneys `json:"triggered_journeys,omitempty"` -} - -func (o *GetOrgPortalConfigResponseBody) GetAccessToken() *string { - if o == nil { - return nil - } - return o.AccessToken -} - -func (o *GetOrgPortalConfigResponseBody) GetAdvancedMfa() *AdvancedMfa { - if o == nil { - return nil - } - return o.AdvancedMfa -} - -func (o *GetOrgPortalConfigResponseBody) GetAllowedFileExtensions() *shared.AllowedFileExtensions { - if o == nil { - return nil - } - return o.AllowedFileExtensions -} - -func (o *GetOrgPortalConfigResponseBody) GetApprovalStateAttributes() map[string][]string { - if o == nil { - return nil - } - return o.ApprovalStateAttributes -} - -func (o *GetOrgPortalConfigResponseBody) GetAuthSettings() *AuthSettings { - if o == nil { - return nil - } - return o.AuthSettings -} - -func (o *GetOrgPortalConfigResponseBody) GetCertificateDetails() *CertificateDetails { - if o == nil { - return nil - } - return o.CertificateDetails -} - -func (o *GetOrgPortalConfigResponseBody) GetCognitoDetails() *CognitoDetails { - if o == nil { - return nil - } - return o.CognitoDetails -} - -func (o *GetOrgPortalConfigResponseBody) GetConfig() *string { - if o == nil { - return nil - } - return o.Config -} - -func (o *GetOrgPortalConfigResponseBody) GetContactIdentifiers() []string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *GetOrgPortalConfigResponseBody) GetContractIdentifiers() []shared.ContractIdentifier { - if o == nil { - return nil - } - return o.ContractIdentifiers -} - -func (o *GetOrgPortalConfigResponseBody) GetContractSelectorConfig() *ContractSelectorConfig { - if o == nil { - return nil - } - return o.ContractSelectorConfig -} - -func (o *GetOrgPortalConfigResponseBody) GetDesignID() *string { - if o == nil { - return nil - } - return o.DesignID -} - -func (o *GetOrgPortalConfigResponseBody) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *GetOrgPortalConfigResponseBody) GetEmailTemplates() *shared.EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *GetOrgPortalConfigResponseBody) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *GetOrgPortalConfigResponseBody) GetEntityEditRules() []EntityEditRules { - if o == nil { - return nil - } - return o.EntityEditRules -} - -func (o *GetOrgPortalConfigResponseBody) GetEntityIdentifiers() *EntityIdentifiers { - if o == nil { - return nil - } - return o.EntityIdentifiers -} - -func (o *GetOrgPortalConfigResponseBody) GetFeatureFlags() map[string]bool { - if o == nil { - return nil - } - return o.FeatureFlags -} - -func (o *GetOrgPortalConfigResponseBody) GetFeatureSettings() *FeatureSettings { - if o == nil { - return nil - } - return o.FeatureSettings -} - -func (o *GetOrgPortalConfigResponseBody) GetGrants() []shared.Grant { - if o == nil { - return nil - } - return o.Grants -} - -func (o *GetOrgPortalConfigResponseBody) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *GetOrgPortalConfigResponseBody) GetIdentityProviders() []shared.ProviderPublicConfig { - if o == nil { - return nil - } - return o.IdentityProviders -} - -func (o *GetOrgPortalConfigResponseBody) GetImages() *Images { - if o == nil { - return nil - } - return o.Images -} - -func (o *GetOrgPortalConfigResponseBody) GetInactiveContractCutoffYears() *float64 { - if o == nil { - return nil - } - return o.InactiveContractCutoffYears -} - -func (o *GetOrgPortalConfigResponseBody) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} - -func (o *GetOrgPortalConfigResponseBody) GetIsEpilotDomain() *bool { - if o == nil { - return nil - } - return o.IsEpilotDomain -} - -func (o *GetOrgPortalConfigResponseBody) GetIsV3Item() *bool { - if o == nil { - return nil - } - return o.IsV3Item -} - -func (o *GetOrgPortalConfigResponseBody) GetMeterReadingGracePeriod() *float64 { - if o == nil { - return nil - } - return o.MeterReadingGracePeriod -} - -func (o *GetOrgPortalConfigResponseBody) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *GetOrgPortalConfigResponseBody) GetOrgSettings() *OrgSettings { - if o == nil { - return nil - } - return o.OrgSettings -} - -func (o *GetOrgPortalConfigResponseBody) GetOrganizationID() *string { - if o == nil { - return nil - } - return o.OrganizationID -} - -func (o *GetOrgPortalConfigResponseBody) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -func (o *GetOrgPortalConfigResponseBody) GetPages() map[string]shared.Page { - if o == nil { - return nil - } - return o.Pages -} - -func (o *GetOrgPortalConfigResponseBody) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -func (o *GetOrgPortalConfigResponseBody) GetPortalSkV3() *string { - if o == nil { - return nil - } - return o.PortalSkV3 -} - -func (o *GetOrgPortalConfigResponseBody) GetPreventSearchEngineIndexing() *bool { - if o == nil { - return nil - } - return o.PreventSearchEngineIndexing -} - -func (o *GetOrgPortalConfigResponseBody) GetRegistrationIdentifiers() []shared.ContractIdentifier { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} - -func (o *GetOrgPortalConfigResponseBody) GetSelfRegistrationSetting() *SelfRegistrationSetting { - if o == nil { - return nil - } - return o.SelfRegistrationSetting -} - -func (o *GetOrgPortalConfigResponseBody) GetTriggeredJourneys() []TriggeredJourneys { - if o == nil { - return nil - } - return o.TriggeredJourneys -} - -type GetOrgPortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal config retrieved successfully. - Object *GetOrgPortalConfigResponseBody -} - -func (o *GetOrgPortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetOrgPortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetOrgPortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetOrgPortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetOrgPortalConfigResponse) GetObject() *GetOrgPortalConfigResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getportalconfig.go b/internal/sdk/models/operations/getportalconfig.go deleted file mode 100644 index d940137..0000000 --- a/internal/sdk/models/operations/getportalconfig.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalConfigRequest struct { - // Origin of the portal - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPortalConfigRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -type GetPortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // Portal config retrieved successfully. - PortalConfig *shared.PortalConfig - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalConfigResponse) GetPortalConfig() *shared.PortalConfig { - if o == nil { - return nil - } - return o.PortalConfig -} - -func (o *GetPortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getportalconfigbydomain.go b/internal/sdk/models/operations/getportalconfigbydomain.go deleted file mode 100644 index fc371a5..0000000 --- a/internal/sdk/models/operations/getportalconfigbydomain.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalConfigByDomainRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *GetPortalConfigByDomainRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -type GetPortalConfigByDomainResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // Portal config retrieved successfully. - PortalConfig *shared.PortalConfig - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPortalConfigByDomainResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalConfigByDomainResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalConfigByDomainResponse) GetPortalConfig() *shared.PortalConfig { - if o == nil { - return nil - } - return o.PortalConfig -} - -func (o *GetPortalConfigByDomainResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalConfigByDomainResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getportalconfigv3.go b/internal/sdk/models/operations/getportalconfigv3.go deleted file mode 100644 index f3869fd..0000000 --- a/internal/sdk/models/operations/getportalconfigv3.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalConfigV3Request struct { - // Portal ID (readonly UUID generated on portal creation) - PortalID string `pathParam:"style=simple,explode=false,name=portal_id"` -} - -func (o *GetPortalConfigV3Request) GetPortalID() string { - if o == nil { - return "" - } - return o.PortalID -} - -type GetPortalConfigV3Response struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // Portal config retrieved successfully. - PortalConfigV3 *shared.PortalConfigV3 - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPortalConfigV3Response) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalConfigV3Response) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalConfigV3Response) GetPortalConfigV3() *shared.PortalConfigV3 { - if o == nil { - return nil - } - return o.PortalConfigV3 -} - -func (o *GetPortalConfigV3Response) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalConfigV3Response) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getportalextensions.go b/internal/sdk/models/operations/getportalextensions.go deleted file mode 100644 index 83c41d6..0000000 --- a/internal/sdk/models/operations/getportalextensions.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalExtensionsRequest struct { - // Origin of the portal - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPortalExtensionsRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -type GetPortalExtensionsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal extensions retrieved successfully. - Classes []shared.Extension -} - -func (o *GetPortalExtensionsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalExtensionsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalExtensionsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalExtensionsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPortalExtensionsResponse) GetClasses() []shared.Extension { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getportalpage.go b/internal/sdk/models/operations/getportalpage.go deleted file mode 100644 index 5a14466..0000000 --- a/internal/sdk/models/operations/getportalpage.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalPageRequest struct { - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetPortalPageRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type GetPortalPageResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // The portal page has been fetched successfully. - Page *shared.Page - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPortalPageResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalPageResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalPageResponse) GetPage() *shared.Page { - if o == nil { - return nil - } - return o.Page -} - -func (o *GetPortalPageResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalPageResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getportalpageblock.go b/internal/sdk/models/operations/getportalpageblock.go deleted file mode 100644 index 84260dd..0000000 --- a/internal/sdk/models/operations/getportalpageblock.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalPageBlockRequest struct { - BlockID string `pathParam:"style=simple,explode=false,name=block_id"` - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetPortalPageBlockRequest) GetBlockID() string { - if o == nil { - return "" - } - return o.BlockID -} - -func (o *GetPortalPageBlockRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type GetPortalPageBlockResponse struct { - // The portal page block has been fetched successfully. - Block *shared.Block - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPortalPageBlockResponse) GetBlock() *shared.Block { - if o == nil { - return nil - } - return o.Block -} - -func (o *GetPortalPageBlockResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalPageBlockResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalPageBlockResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalPageBlockResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getportalpageblocks.go b/internal/sdk/models/operations/getportalpageblocks.go deleted file mode 100644 index bf3855c..0000000 --- a/internal/sdk/models/operations/getportalpageblocks.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalPageBlocksRequest struct { - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *GetPortalPageBlocksRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type GetPortalPageBlocksResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The portal page blocks have been fetched successfully. - Classes []shared.Block -} - -func (o *GetPortalPageBlocksResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalPageBlocksResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalPageBlocksResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalPageBlocksResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPortalPageBlocksResponse) GetClasses() []shared.Block { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getportalpages.go b/internal/sdk/models/operations/getportalpages.go deleted file mode 100644 index 721dc4c..0000000 --- a/internal/sdk/models/operations/getportalpages.go +++ /dev/null @@ -1,126 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type QueryParamContextEntities struct { - // Entity id - EntityID string `queryParam:"name=entity_id"` - // Entity schema - EntitySchema string `queryParam:"name=entity_schema"` -} - -func (o *QueryParamContextEntities) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *QueryParamContextEntities) GetEntitySchema() string { - if o == nil { - return "" - } - return o.EntitySchema -} - -type GetPortalPagesRequest struct { - // If the request is in a context of certain entities (i.e. the user in in a context of a specific contract), pages can be customized for that. Portal User and Contact entities are automatically part of the context. - ContextEntities []QueryParamContextEntities `queryParam:"style=form,explode=true,name=context_entities"` - // Contract context for blocks. Use context_entities instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContractID *string `queryParam:"style=form,explode=true,name=contract_id"` - Domain string `queryParam:"style=form,explode=true,name=domain"` - // The fields to include in the response - Fields *string `queryParam:"style=form,explode=true,name=fields"` - // The filter to apply to the response - Filter *string `queryParam:"style=form,explode=true,name=filter"` -} - -func (o *GetPortalPagesRequest) GetContextEntities() []QueryParamContextEntities { - if o == nil { - return nil - } - return o.ContextEntities -} - -func (o *GetPortalPagesRequest) GetContractID() *string { - if o == nil { - return nil - } - return o.ContractID -} - -func (o *GetPortalPagesRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *GetPortalPagesRequest) GetFields() *string { - if o == nil { - return nil - } - return o.Fields -} - -func (o *GetPortalPagesRequest) GetFilter() *string { - if o == nil { - return nil - } - return o.Filter -} - -type GetPortalPagesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The portal pages have been fetched successfully. - Classes []shared.Page -} - -func (o *GetPortalPagesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalPagesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalPagesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalPagesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPortalPagesResponse) GetClasses() []shared.Page { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getportaluser.go b/internal/sdk/models/operations/getportaluser.go deleted file mode 100644 index 67db0f7..0000000 --- a/internal/sdk/models/operations/getportaluser.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetPortalUserResponseBody - Portal user returned successfully. -type GetPortalUserResponseBody struct { - // The portal user entity - Data *shared.PortalUser `json:"data,omitempty"` -} - -func (o *GetPortalUserResponseBody) GetData() *shared.PortalUser { - if o == nil { - return nil - } - return o.Data -} - -type GetPortalUserResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal user returned successfully. - Object *GetPortalUserResponseBody -} - -func (o *GetPortalUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPortalUserResponse) GetObject() *GetPortalUserResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getportalwidgets.go b/internal/sdk/models/operations/getportalwidgets.go deleted file mode 100644 index dc54cbf..0000000 --- a/internal/sdk/models/operations/getportalwidgets.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPortalWidgetsRequest struct { - // Contract context for widgets - ContractID *string `queryParam:"style=form,explode=true,name=contract_id"` - // Origin of the portal - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPortalWidgetsRequest) GetContractID() *string { - if o == nil { - return nil - } - return o.ContractID -} - -func (o *GetPortalWidgetsRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -type GetPortalWidgetsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved the portal widgets successfully. - UpsertPortalWidget *shared.UpsertPortalWidget -} - -func (o *GetPortalWidgetsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPortalWidgetsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPortalWidgetsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPortalWidgetsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPortalWidgetsResponse) GetUpsertPortalWidget() *shared.UpsertPortalWidget { - if o == nil { - return nil - } - return o.UpsertPortalWidget -} diff --git a/internal/sdk/models/operations/getprices.go b/internal/sdk/models/operations/getprices.go deleted file mode 100644 index 572262c..0000000 --- a/internal/sdk/models/operations/getprices.go +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" - "time" -) - -// GetPricesQueryParamInterval - Interval between price data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. -type GetPricesQueryParamInterval string - -const ( - GetPricesQueryParamIntervalPt15M GetPricesQueryParamInterval = "PT15M" - GetPricesQueryParamIntervalPt1H GetPricesQueryParamInterval = "PT1H" - GetPricesQueryParamIntervalP1D GetPricesQueryParamInterval = "P1D" - GetPricesQueryParamIntervalP1M GetPricesQueryParamInterval = "P1M" -) - -func (e GetPricesQueryParamInterval) ToPointer() *GetPricesQueryParamInterval { - return &e -} -func (e *GetPricesQueryParamInterval) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PT15M": - fallthrough - case "PT1H": - fallthrough - case "P1D": - fallthrough - case "P1M": - *e = GetPricesQueryParamInterval(v) - return nil - default: - return fmt.Errorf("invalid value for GetPricesQueryParamInterval: %v", v) - } -} - -type GetPricesRequest struct { - // Extension ID for price data. - ExtensionID string `queryParam:"style=form,explode=true,name=extensionId"` - // Start date for price data (ISO 8601 format). - From time.Time `queryParam:"style=form,explode=true,name=from"` - // Hook ID for price data. - HookID string `queryParam:"style=form,explode=true,name=hookId"` - // Interval between price data points (e.g., PT15M for 15 minutes, PT1H for hourly). Not all intervals have to be supported. - Interval GetPricesQueryParamInterval `queryParam:"style=form,explode=true,name=interval"` - // Meter ID for price data. - MeterID string `queryParam:"style=form,explode=true,name=meter_id"` - // End date for price data (ISO 8601 format). - To time.Time `queryParam:"style=form,explode=true,name=to"` -} - -func (g GetPricesRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetPricesRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"extensionId", "from", "hookId", "interval", "meter_id", "to"}); err != nil { - return err - } - return nil -} - -func (o *GetPricesRequest) GetExtensionID() string { - if o == nil { - return "" - } - return o.ExtensionID -} - -func (o *GetPricesRequest) GetFrom() time.Time { - if o == nil { - return time.Time{} - } - return o.From -} - -func (o *GetPricesRequest) GetHookID() string { - if o == nil { - return "" - } - return o.HookID -} - -func (o *GetPricesRequest) GetInterval() GetPricesQueryParamInterval { - if o == nil { - return GetPricesQueryParamInterval("") - } - return o.Interval -} - -func (o *GetPricesRequest) GetMeterID() string { - if o == nil { - return "" - } - return o.MeterID -} - -func (o *GetPricesRequest) GetTo() time.Time { - if o == nil { - return time.Time{} - } - return o.To -} - -// Components - Optional price components. -type Components struct { - // Market price in cents, e.g. 1000 for 10,00 €. - AuctionPriceAmount *int64 `json:"auction_price_amount,omitempty"` - // Market price in decimal format, e.g. "10.00". - AuctionPriceAmountDecimal *string `json:"auction_price_amount_decimal,omitempty"` - // Fee associated with the transmission/distribution in cents, e.g. 100 for 1,00 €. - GridFeeAmount *int64 `json:"grid_fee_amount,omitempty"` - // Fee associated with the transmission/distribution in decimal format, e.g. "1.00". - GridFeeAmountDecimal *string `json:"grid_fee_amount_decimal,omitempty"` - // Margin in cents, e.g. 34 for 0,34 €. - MarginAmount *int64 `json:"margin_amount,omitempty"` - // Margin in decimal format, e.g. "0.34". - MarginAmountDecimal *string `json:"margin_amount_decimal,omitempty"` - // Fee associated with the source, e.g. Green Energy Certificate fee in cents, e.g. 50 for 00,50 €. - SourceFeeAmount *int64 `json:"source_fee_amount,omitempty"` - // Fee associated with the source, e.g. Green Energy Certificate fee in decimal format, e.g. "0.50". - SourceFeeAmountDecimal *string `json:"source_fee_amount_decimal,omitempty"` - // Taxes/Levies other than tax specified on the price level in cents, e.g. 50 for 00,50 €. - TaxesLeviesAmount *int64 `json:"taxes_levies_amount,omitempty"` - // Taxes/Levies other than tax specified on the price level in decimal format, e.g. "0.50". - TaxesLeviesAmountDecimal *string `json:"taxes_levies_amount_decimal,omitempty"` -} - -func (o *Components) GetAuctionPriceAmount() *int64 { - if o == nil { - return nil - } - return o.AuctionPriceAmount -} - -func (o *Components) GetAuctionPriceAmountDecimal() *string { - if o == nil { - return nil - } - return o.AuctionPriceAmountDecimal -} - -func (o *Components) GetGridFeeAmount() *int64 { - if o == nil { - return nil - } - return o.GridFeeAmount -} - -func (o *Components) GetGridFeeAmountDecimal() *string { - if o == nil { - return nil - } - return o.GridFeeAmountDecimal -} - -func (o *Components) GetMarginAmount() *int64 { - if o == nil { - return nil - } - return o.MarginAmount -} - -func (o *Components) GetMarginAmountDecimal() *string { - if o == nil { - return nil - } - return o.MarginAmountDecimal -} - -func (o *Components) GetSourceFeeAmount() *int64 { - if o == nil { - return nil - } - return o.SourceFeeAmount -} - -func (o *Components) GetSourceFeeAmountDecimal() *string { - if o == nil { - return nil - } - return o.SourceFeeAmountDecimal -} - -func (o *Components) GetTaxesLeviesAmount() *int64 { - if o == nil { - return nil - } - return o.TaxesLeviesAmount -} - -func (o *Components) GetTaxesLeviesAmountDecimal() *string { - if o == nil { - return nil - } - return o.TaxesLeviesAmountDecimal -} - -// GetPricesTaxBehavior - Is the tax (typically Value Added Tax) included in the amounts. Typically should NOT be included - exclusive of tax. -type GetPricesTaxBehavior string - -const ( - GetPricesTaxBehaviorInclusive GetPricesTaxBehavior = "inclusive" - GetPricesTaxBehaviorExclusive GetPricesTaxBehavior = "exclusive" -) - -func (e GetPricesTaxBehavior) ToPointer() *GetPricesTaxBehavior { - return &e -} -func (e *GetPricesTaxBehavior) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "inclusive": - fallthrough - case "exclusive": - *e = GetPricesTaxBehavior(v) - return nil - default: - return fmt.Errorf("invalid value for GetPricesTaxBehavior: %v", v) - } -} - -type Prices struct { - // Optional price components. - Components *Components `json:"components,omitempty"` - // Is the tax (typically Value Added Tax) included in the amounts. Typically should NOT be included - exclusive of tax. - TaxBehavior GetPricesTaxBehavior `json:"tax_behavior"` - // Tax rate in percent, e.g. 19 for 19%. - TaxRate int64 `json:"tax_rate"` - // ISO 8601 timestamp of the price record. - Timestamp time.Time `json:"timestamp"` - // Cost in cents, e.g. 1234 for 12,34 €. - UnitAmount int64 `json:"unit_amount"` - // ISO 4217:2015 currency. - UnitAmountCurrency string `json:"unit_amount_currency"` - // Cost in decimal format, e.g. "12.34". - UnitAmountDecimal string `json:"unit_amount_decimal"` -} - -func (p Prices) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *Prices) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"tax_behavior", "tax_rate", "timestamp", "unit_amount", "unit_amount_currency", "unit_amount_decimal"}); err != nil { - return err - } - return nil -} - -func (o *Prices) GetComponents() *Components { - if o == nil { - return nil - } - return o.Components -} - -func (o *Prices) GetTaxBehavior() GetPricesTaxBehavior { - if o == nil { - return GetPricesTaxBehavior("") - } - return o.TaxBehavior -} - -func (o *Prices) GetTaxRate() int64 { - if o == nil { - return 0 - } - return o.TaxRate -} - -func (o *Prices) GetTimestamp() time.Time { - if o == nil { - return time.Time{} - } - return o.Timestamp -} - -func (o *Prices) GetUnitAmount() int64 { - if o == nil { - return 0 - } - return o.UnitAmount -} - -func (o *Prices) GetUnitAmountCurrency() string { - if o == nil { - return "" - } - return o.UnitAmountCurrency -} - -func (o *Prices) GetUnitAmountDecimal() string { - if o == nil { - return "" - } - return o.UnitAmountDecimal -} - -// GetPricesResponseBody - Price data returned successfully. -type GetPricesResponseBody struct { - Prices []Prices `json:"prices,omitempty"` -} - -func (o *GetPricesResponseBody) GetPrices() []Prices { - if o == nil { - return nil - } - return o.Prices -} - -type GetPricesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Price data returned successfully. - Object *GetPricesResponseBody -} - -func (o *GetPricesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPricesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPricesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPricesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPricesResponse) GetObject() *GetPricesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getpublicpages.go b/internal/sdk/models/operations/getpublicpages.go deleted file mode 100644 index 7ae9d7c..0000000 --- a/internal/sdk/models/operations/getpublicpages.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPublicPagesRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` - // The fields to include in the response - Fields *string `queryParam:"style=form,explode=true,name=fields"` - // The filter to apply to the response - Filter *string `queryParam:"style=form,explode=true,name=filter"` -} - -func (o *GetPublicPagesRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *GetPublicPagesRequest) GetFields() *string { - if o == nil { - return nil - } - return o.Fields -} - -func (o *GetPublicPagesRequest) GetFilter() *string { - if o == nil { - return nil - } - return o.Filter -} - -type GetPublicPagesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The portal pages have been fetched successfully. - Classes []shared.Page -} - -func (o *GetPublicPagesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPublicPagesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPublicPagesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPublicPagesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPublicPagesResponse) GetClasses() []shared.Page { - if o == nil { - return nil - } - return o.Classes -} diff --git a/internal/sdk/models/operations/getpublicportalconfig.go b/internal/sdk/models/operations/getpublicportalconfig.go deleted file mode 100644 index 5d814ca..0000000 --- a/internal/sdk/models/operations/getpublicportalconfig.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPublicPortalConfigRequest struct { - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPublicPortalConfigRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *GetPublicPortalConfigRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type GetPublicPortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // Portal config retrieved successfully. - PortalConfig *shared.PortalConfig - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPublicPortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPublicPortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPublicPortalConfigResponse) GetPortalConfig() *shared.PortalConfig { - if o == nil { - return nil - } - return o.PortalConfig -} - -func (o *GetPublicPortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPublicPortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getpublicportalextensiondetails.go b/internal/sdk/models/operations/getpublicportalextensiondetails.go deleted file mode 100644 index 4128050..0000000 --- a/internal/sdk/models/operations/getpublicportalextensiondetails.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPublicPortalExtensionDetailsRequest struct { - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPublicPortalExtensionDetailsRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *GetPublicPortalExtensionDetailsRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type GetPublicPortalExtensionDetailsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // Public details of extensions. - PublicExtensionCapabilities *shared.PublicExtensionCapabilities - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetPublicPortalExtensionDetailsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPublicPortalExtensionDetailsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPublicPortalExtensionDetailsResponse) GetPublicExtensionCapabilities() *shared.PublicExtensionCapabilities { - if o == nil { - return nil - } - return o.PublicExtensionCapabilities -} - -func (o *GetPublicPortalExtensionDetailsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPublicPortalExtensionDetailsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getpublicportalwidgets.go b/internal/sdk/models/operations/getpublicportalwidgets.go deleted file mode 100644 index 500ad11..0000000 --- a/internal/sdk/models/operations/getpublicportalwidgets.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetPublicPortalWidgetsRequest struct { - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetPublicPortalWidgetsRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *GetPublicPortalWidgetsRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type GetPublicPortalWidgetsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved the portal public widgets successfully. - UpsertPortalWidget *shared.UpsertPortalWidget -} - -func (o *GetPublicPortalWidgetsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetPublicPortalWidgetsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetPublicPortalWidgetsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetPublicPortalWidgetsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetPublicPortalWidgetsResponse) GetUpsertPortalWidget() *shared.UpsertPortalWidget { - if o == nil { - return nil - } - return o.UpsertPortalWidget -} diff --git a/internal/sdk/models/operations/getrecipientstonotifyonautomation.go b/internal/sdk/models/operations/getrecipientstonotifyonautomation.go deleted file mode 100644 index c39ff42..0000000 --- a/internal/sdk/models/operations/getrecipientstonotifyonautomation.go +++ /dev/null @@ -1,129 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetRecipientsToNotifyOnAutomationRequestBody struct { - // Entity ID - ContextID string `json:"context_id"` - // Emails array that are part of the automation - Emails []string `json:"emails"` - // Entity ID - TemplateID string `json:"template_id"` -} - -func (o *GetRecipientsToNotifyOnAutomationRequestBody) GetContextID() string { - if o == nil { - return "" - } - return o.ContextID -} - -func (o *GetRecipientsToNotifyOnAutomationRequestBody) GetEmails() []string { - if o == nil { - return []string{} - } - return o.Emails -} - -func (o *GetRecipientsToNotifyOnAutomationRequestBody) GetTemplateID() string { - if o == nil { - return "" - } - return o.TemplateID -} - -type Recipients struct { - // Email of the recipient - Email string `json:"email"` - // Entity ID - RecipientID string `json:"recipient_id"` -} - -func (o *Recipients) GetEmail() string { - if o == nil { - return "" - } - return o.Email -} - -func (o *Recipients) GetRecipientID() string { - if o == nil { - return "" - } - return o.RecipientID -} - -// GetRecipientsToNotifyOnAutomationResponseBody - Returns the valid recipients to notify successfully. -type GetRecipientsToNotifyOnAutomationResponseBody struct { - // Reason to not notify the user - Message *string `json:"message,omitempty"` - // Filtered recipients to notify - Recipients []Recipients `json:"recipients,omitempty"` -} - -func (o *GetRecipientsToNotifyOnAutomationResponseBody) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} - -func (o *GetRecipientsToNotifyOnAutomationResponseBody) GetRecipients() []Recipients { - if o == nil { - return nil - } - return o.Recipients -} - -type GetRecipientsToNotifyOnAutomationResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Returns the valid recipients to notify successfully. - Object *GetRecipientsToNotifyOnAutomationResponseBody -} - -func (o *GetRecipientsToNotifyOnAutomationResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetRecipientsToNotifyOnAutomationResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetRecipientsToNotifyOnAutomationResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetRecipientsToNotifyOnAutomationResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetRecipientsToNotifyOnAutomationResponse) GetObject() *GetRecipientsToNotifyOnAutomationResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getregistrationidentifiers.go b/internal/sdk/models/operations/getregistrationidentifiers.go deleted file mode 100644 index d49d884..0000000 --- a/internal/sdk/models/operations/getregistrationidentifiers.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetRegistrationIdentifiersResponseBody - A dictionary of identifier attributes per entity schema are returned successfully. -type GetRegistrationIdentifiersResponseBody struct { - Data map[string][]shared.IdentifierAttribute `json:"data,omitempty"` -} - -func (o *GetRegistrationIdentifiersResponseBody) GetData() map[string][]shared.IdentifierAttribute { - if o == nil { - return nil - } - return o.Data -} - -type GetRegistrationIdentifiersResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // A dictionary of identifier attributes per entity schema are returned successfully. - Object *GetRegistrationIdentifiersResponseBody -} - -func (o *GetRegistrationIdentifiersResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetRegistrationIdentifiersResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetRegistrationIdentifiersResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetRegistrationIdentifiersResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetRegistrationIdentifiersResponse) GetObject() *GetRegistrationIdentifiersResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getresolvedexternallink.go b/internal/sdk/models/operations/getresolvedexternallink.go deleted file mode 100644 index b0f3695..0000000 --- a/internal/sdk/models/operations/getresolvedexternallink.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetResolvedExternalLinkRequest struct { - // Contact ID of the user - ContactID *string `queryParam:"style=form,explode=true,name=contactId"` - // ID of the External Link - ID string `pathParam:"style=simple,explode=false,name=id"` - // Origin of the portal - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *GetResolvedExternalLinkRequest) GetContactID() *string { - if o == nil { - return nil - } - return o.ContactID -} - -func (o *GetResolvedExternalLinkRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *GetResolvedExternalLinkRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -type GetResolvedExternalLinkResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // Resolved portal config link retrieved successfully. - ExternalLink *shared.ExternalLink - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *GetResolvedExternalLinkResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetResolvedExternalLinkResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetResolvedExternalLinkResponse) GetExternalLink() *shared.ExternalLink { - if o == nil { - return nil - } - return o.ExternalLink -} - -func (o *GetResolvedExternalLinkResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetResolvedExternalLinkResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/getresolvedseamlesslink.go b/internal/sdk/models/operations/getresolvedseamlesslink.go deleted file mode 100644 index 1427cba..0000000 --- a/internal/sdk/models/operations/getresolvedseamlesslink.go +++ /dev/null @@ -1,129 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ContextEntities struct { - // Entity id - EntityID string `queryParam:"name=entity_id"` - // Entity schema - EntitySchema string `queryParam:"name=entity_schema"` -} - -func (o *ContextEntities) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *ContextEntities) GetEntitySchema() string { - if o == nil { - return "" - } - return o.EntitySchema -} - -type GetResolvedSeamlessLinkRequest struct { - // ID of the App if the Portal Extension was installed from an App - AppID *string `queryParam:"style=form,explode=true,name=app_id"` - // If the request is in a context of certain entities (i.e. the user in in a context of a specific contract), links can be customized for that. Portal User and Contact entities are automatically part of the context. - ContextEntities []ContextEntities `queryParam:"style=form,explode=true,name=context_entities"` - // ID of the Portal Extension - ExtensionID string `queryParam:"style=form,explode=true,name=extension_id"` - // ID of the Seamless Link - LinkID string `queryParam:"style=form,explode=true,name=link_id"` -} - -func (o *GetResolvedSeamlessLinkRequest) GetAppID() *string { - if o == nil { - return nil - } - return o.AppID -} - -func (o *GetResolvedSeamlessLinkRequest) GetContextEntities() []ContextEntities { - if o == nil { - return nil - } - return o.ContextEntities -} - -func (o *GetResolvedSeamlessLinkRequest) GetExtensionID() string { - if o == nil { - return "" - } - return o.ExtensionID -} - -func (o *GetResolvedSeamlessLinkRequest) GetLinkID() string { - if o == nil { - return "" - } - return o.LinkID -} - -// GetResolvedSeamlessLinkResponseBody - Resolved portal seamless link retrieved successfully. -type GetResolvedSeamlessLinkResponseBody struct { - // Resolved link - Link *string `json:"link,omitempty"` -} - -func (o *GetResolvedSeamlessLinkResponseBody) GetLink() *string { - if o == nil { - return nil - } - return o.Link -} - -type GetResolvedSeamlessLinkResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Resolved portal seamless link retrieved successfully. - Object *GetResolvedSeamlessLinkResponseBody -} - -func (o *GetResolvedSeamlessLinkResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetResolvedSeamlessLinkResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetResolvedSeamlessLinkResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetResolvedSeamlessLinkResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetResolvedSeamlessLinkResponse) GetObject() *GetResolvedSeamlessLinkResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getrole.go b/internal/sdk/models/operations/getrole.go new file mode 100644 index 0000000..54489cd --- /dev/null +++ b/internal/sdk/models/operations/getrole.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +type GetRoleRequest struct { + RoleID string `pathParam:"style=simple,explode=false,name=roleId"` +} + +func (g *GetRoleRequest) GetRoleID() string { + if g == nil { + return "" + } + return g.RoleID +} + +type GetRoleResponse struct { + // HTTP response content type for this operation + ContentType string + // ok + Role *shared.Role + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (g *GetRoleResponse) GetContentType() string { + if g == nil { + return "" + } + return g.ContentType +} + +func (g *GetRoleResponse) GetRole() *shared.Role { + if g == nil { + return nil + } + return g.Role +} + +func (g *GetRoleResponse) GetStatusCode() int { + if g == nil { + return 0 + } + return g.StatusCode +} + +func (g *GetRoleResponse) GetRawResponse() *http.Response { + if g == nil { + return nil + } + return g.RawResponse +} diff --git a/internal/sdk/models/operations/getschemas.go b/internal/sdk/models/operations/getschemas.go deleted file mode 100644 index 68f8d6a..0000000 --- a/internal/sdk/models/operations/getschemas.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// GetSchemasResponseBody - Retrieved schemas for an organization successfully. -type GetSchemasResponseBody struct { - Schemas []shared.Schema `json:"schemas,omitempty"` -} - -func (o *GetSchemasResponseBody) GetSchemas() []shared.Schema { - if o == nil { - return nil - } - return o.Schemas -} - -type GetSchemasResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved schemas for an organization successfully. - Object *GetSchemasResponseBody -} - -func (o *GetSchemasResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetSchemasResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetSchemasResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetSchemasResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetSchemasResponse) GetObject() *GetSchemasResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getschemasbydomain.go b/internal/sdk/models/operations/getschemasbydomain.go deleted file mode 100644 index 10e2a5f..0000000 --- a/internal/sdk/models/operations/getschemasbydomain.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetSchemasByDomainRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *GetSchemasByDomainRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -// GetSchemasByDomainResponseBody - Retrieved schemas for an organization successfully. -type GetSchemasByDomainResponseBody struct { - Schemas []shared.Schema `json:"schemas,omitempty"` -} - -func (o *GetSchemasByDomainResponseBody) GetSchemas() []shared.Schema { - if o == nil { - return nil - } - return o.Schemas -} - -type GetSchemasByDomainResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Retrieved schemas for an organization successfully. - Object *GetSchemasByDomainResponseBody -} - -func (o *GetSchemasByDomainResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetSchemasByDomainResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetSchemasByDomainResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetSchemasByDomainResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetSchemasByDomainResponse) GetObject() *GetSchemasByDomainResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getsearchableattributesforopportunities.go b/internal/sdk/models/operations/getsearchableattributesforopportunities.go deleted file mode 100644 index f678194..0000000 --- a/internal/sdk/models/operations/getsearchableattributesforopportunities.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetSearchableAttributesForOpportunitiesRequest struct { - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"1000" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetSearchableAttributesForOpportunitiesRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetSearchableAttributesForOpportunitiesRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GetSearchableAttributesForOpportunitiesRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetSearchableAttributesForOpportunitiesRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -// GetSearchableAttributesForOpportunitiesResponseBody - The opportunities is retrieved successfully for the portal user. -type GetSearchableAttributesForOpportunitiesResponseBody struct { - Data []shared.Opportunity `json:"data,omitempty"` -} - -func (o *GetSearchableAttributesForOpportunitiesResponseBody) GetData() []shared.Opportunity { - if o == nil { - return nil - } - return o.Data -} - -type GetSearchableAttributesForOpportunitiesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The opportunities is retrieved successfully for the portal user. - Object *GetSearchableAttributesForOpportunitiesResponseBody -} - -func (o *GetSearchableAttributesForOpportunitiesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetSearchableAttributesForOpportunitiesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetSearchableAttributesForOpportunitiesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetSearchableAttributesForOpportunitiesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetSearchableAttributesForOpportunitiesResponse) GetObject() *GetSearchableAttributesForOpportunitiesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getsearchresultsforopportunities.go b/internal/sdk/models/operations/getsearchresultsforopportunities.go deleted file mode 100644 index a65ea70..0000000 --- a/internal/sdk/models/operations/getsearchresultsforopportunities.go +++ /dev/null @@ -1,161 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type Workflows struct { - DefitionID *string `json:"defition_id,omitempty"` - Name *string `json:"name,omitempty"` -} - -func (o *Workflows) GetDefitionID() *string { - if o == nil { - return nil - } - return o.DefitionID -} - -func (o *Workflows) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -type GetSearchResultsForOpportunitiesRequestBody struct { - Addresses []string `json:"addresses,omitempty"` - Customers []string `json:"customers,omitempty"` - Purposes []string `json:"purposes,omitempty"` - Workflows [][]Workflows `json:"workflows,omitempty"` -} - -func (o *GetSearchResultsForOpportunitiesRequestBody) GetAddresses() []string { - if o == nil { - return nil - } - return o.Addresses -} - -func (o *GetSearchResultsForOpportunitiesRequestBody) GetCustomers() []string { - if o == nil { - return nil - } - return o.Customers -} - -func (o *GetSearchResultsForOpportunitiesRequestBody) GetPurposes() []string { - if o == nil { - return nil - } - return o.Purposes -} - -func (o *GetSearchResultsForOpportunitiesRequestBody) GetWorkflows() [][]Workflows { - if o == nil { - return nil - } - return o.Workflows -} - -type GetSearchResultsForOpportunitiesRequest struct { - RequestBody GetSearchResultsForOpportunitiesRequestBody `request:"mediaType=application/json"` - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"1000" queryParam:"style=form,explode=true,name=size"` -} - -func (g GetSearchResultsForOpportunitiesRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GetSearchResultsForOpportunitiesRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, []string{"RequestBody"}); err != nil { - return err - } - return nil -} - -func (o *GetSearchResultsForOpportunitiesRequest) GetRequestBody() GetSearchResultsForOpportunitiesRequestBody { - if o == nil { - return GetSearchResultsForOpportunitiesRequestBody{} - } - return o.RequestBody -} - -func (o *GetSearchResultsForOpportunitiesRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *GetSearchResultsForOpportunitiesRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -// GetSearchResultsForOpportunitiesResponseBody - The opportunities is retrieved successfully for the portal user. -type GetSearchResultsForOpportunitiesResponseBody struct { - Data []shared.Opportunity `json:"data,omitempty"` -} - -func (o *GetSearchResultsForOpportunitiesResponseBody) GetData() []shared.Opportunity { - if o == nil { - return nil - } - return o.Data -} - -type GetSearchResultsForOpportunitiesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The opportunities is retrieved successfully for the portal user. - Object *GetSearchResultsForOpportunitiesResponseBody -} - -func (o *GetSearchResultsForOpportunitiesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetSearchResultsForOpportunitiesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetSearchResultsForOpportunitiesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetSearchResultsForOpportunitiesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetSearchResultsForOpportunitiesResponse) GetObject() *GetSearchResultsForOpportunitiesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getuserentrypoint.go b/internal/sdk/models/operations/getuserentrypoint.go deleted file mode 100644 index 5f53487..0000000 --- a/internal/sdk/models/operations/getuserentrypoint.go +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetUserEntryPointRequest struct { - Domain string `queryParam:"style=form,explode=true,name=domain"` - Email string `queryParam:"style=form,explode=true,name=email"` -} - -func (o *GetUserEntryPointRequest) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *GetUserEntryPointRequest) GetEmail() string { - if o == nil { - return "" - } - return o.Email -} - -// EntryPoint - The entry point for the user -type EntryPoint string - -const ( - EntryPointPassword EntryPoint = "PASSWORD" - EntryPointSso EntryPoint = "SSO" -) - -func (e EntryPoint) ToPointer() *EntryPoint { - return &e -} -func (e *EntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = EntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for EntryPoint: %v", v) - } -} - -// GetUserEntryPointResponseBody - Returned the entry point for the user -type GetUserEntryPointResponseBody struct { - // The entry point for the user - EntryPoint EntryPoint `json:"entry_point"` - // Whether the user is soft deleted - IsSoftDeleted *bool `json:"is_soft_deleted,omitempty"` - // The SSO providers for the user - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` - // Whether the user exists in the portal - UserExists bool `json:"user_exists"` -} - -func (o *GetUserEntryPointResponseBody) GetEntryPoint() EntryPoint { - if o == nil { - return EntryPoint("") - } - return o.EntryPoint -} - -func (o *GetUserEntryPointResponseBody) GetIsSoftDeleted() *bool { - if o == nil { - return nil - } - return o.IsSoftDeleted -} - -func (o *GetUserEntryPointResponseBody) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -func (o *GetUserEntryPointResponseBody) GetUserExists() bool { - if o == nil { - return false - } - return o.UserExists -} - -type GetUserEntryPointResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Returned the entry point for the user - Object *GetUserEntryPointResponseBody -} - -func (o *GetUserEntryPointResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetUserEntryPointResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetUserEntryPointResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetUserEntryPointResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetUserEntryPointResponse) GetObject() *GetUserEntryPointResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/getvalidsecondaryattributes.go b/internal/sdk/models/operations/getvalidsecondaryattributes.go deleted file mode 100644 index f128a55..0000000 --- a/internal/sdk/models/operations/getvalidsecondaryattributes.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type GetValidSecondaryAttributesData struct { - // Name of the secondary attribute - Name *string `json:"name,omitempty"` - // Type of the secondary attribute - Type *string `json:"type,omitempty"` -} - -func (o *GetValidSecondaryAttributesData) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *GetValidSecondaryAttributesData) GetType() *string { - if o == nil { - return nil - } - return o.Type -} - -// GetValidSecondaryAttributesResponseBody - Valid secondary attributes for the contact entity are returned successfully. -type GetValidSecondaryAttributesResponseBody struct { - Data []GetValidSecondaryAttributesData `json:"data,omitempty"` -} - -func (o *GetValidSecondaryAttributesResponseBody) GetData() []GetValidSecondaryAttributesData { - if o == nil { - return nil - } - return o.Data -} - -type GetValidSecondaryAttributesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Valid secondary attributes for the contact entity are returned successfully. - Object *GetValidSecondaryAttributesResponseBody -} - -func (o *GetValidSecondaryAttributesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *GetValidSecondaryAttributesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *GetValidSecondaryAttributesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *GetValidSecondaryAttributesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *GetValidSecondaryAttributesResponse) GetObject() *GetValidSecondaryAttributesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/listallassignments.go b/internal/sdk/models/operations/listallassignments.go new file mode 100644 index 0000000..a79c3bb --- /dev/null +++ b/internal/sdk/models/operations/listallassignments.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +// ListAllAssignmentsResponseBody - ok +type ListAllAssignmentsResponseBody struct { + Assignments []shared.Assignment `json:"assignments,omitempty"` +} + +func (l *ListAllAssignmentsResponseBody) GetAssignments() []shared.Assignment { + if l == nil { + return nil + } + return l.Assignments +} + +type ListAllAssignmentsResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // ok + Object *ListAllAssignmentsResponseBody +} + +func (l *ListAllAssignmentsResponse) GetContentType() string { + if l == nil { + return "" + } + return l.ContentType +} + +func (l *ListAllAssignmentsResponse) GetStatusCode() int { + if l == nil { + return 0 + } + return l.StatusCode +} + +func (l *ListAllAssignmentsResponse) GetRawResponse() *http.Response { + if l == nil { + return nil + } + return l.RawResponse +} + +func (l *ListAllAssignmentsResponse) GetObject() *ListAllAssignmentsResponseBody { + if l == nil { + return nil + } + return l.Object +} diff --git a/internal/sdk/models/operations/listallportalconfigs.go b/internal/sdk/models/operations/listallportalconfigs.go deleted file mode 100644 index 5dbfd89..0000000 --- a/internal/sdk/models/operations/listallportalconfigs.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// ListAllPortalConfigsResponseBody - All portal configs retrieved successfully. -type ListAllPortalConfigsResponseBody struct { - Data []shared.PortalConfigV3 `json:"data,omitempty"` -} - -func (o *ListAllPortalConfigsResponseBody) GetData() []shared.PortalConfigV3 { - if o == nil { - return nil - } - return o.Data -} - -type ListAllPortalConfigsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // All portal configs retrieved successfully. - Object *ListAllPortalConfigsResponseBody -} - -func (o *ListAllPortalConfigsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ListAllPortalConfigsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ListAllPortalConfigsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ListAllPortalConfigsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ListAllPortalConfigsResponse) GetObject() *ListAllPortalConfigsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/listallroles.go b/internal/sdk/models/operations/listallroles.go new file mode 100644 index 0000000..31f10b6 --- /dev/null +++ b/internal/sdk/models/operations/listallroles.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +// ListAllRolesResponseBody - ok +type ListAllRolesResponseBody struct { + Roles []shared.Role `json:"roles,omitempty"` +} + +func (l *ListAllRolesResponseBody) GetRoles() []shared.Role { + if l == nil { + return nil + } + return l.Roles +} + +type ListAllRolesResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // ok + Object *ListAllRolesResponseBody +} + +func (l *ListAllRolesResponse) GetContentType() string { + if l == nil { + return "" + } + return l.ContentType +} + +func (l *ListAllRolesResponse) GetStatusCode() int { + if l == nil { + return 0 + } + return l.StatusCode +} + +func (l *ListAllRolesResponse) GetRawResponse() *http.Response { + if l == nil { + return nil + } + return l.RawResponse +} + +func (l *ListAllRolesResponse) GetObject() *ListAllRolesResponseBody { + if l == nil { + return nil + } + return l.Object +} diff --git a/internal/sdk/models/operations/listcurrentroles.go b/internal/sdk/models/operations/listcurrentroles.go new file mode 100644 index 0000000..6fbfd6a --- /dev/null +++ b/internal/sdk/models/operations/listcurrentroles.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +// ListCurrentRolesResponseBody - ok +type ListCurrentRolesResponseBody struct { + Roles []shared.Role `json:"roles,omitempty"` +} + +func (l *ListCurrentRolesResponseBody) GetRoles() []shared.Role { + if l == nil { + return nil + } + return l.Roles +} + +type ListCurrentRolesResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // ok + Object *ListCurrentRolesResponseBody +} + +func (l *ListCurrentRolesResponse) GetContentType() string { + if l == nil { + return "" + } + return l.ContentType +} + +func (l *ListCurrentRolesResponse) GetStatusCode() int { + if l == nil { + return 0 + } + return l.StatusCode +} + +func (l *ListCurrentRolesResponse) GetRawResponse() *http.Response { + if l == nil { + return nil + } + return l.RawResponse +} + +func (l *ListCurrentRolesResponse) GetObject() *ListCurrentRolesResponseBody { + if l == nil { + return nil + } + return l.Object +} diff --git a/internal/sdk/models/operations/listportalsinternal.go b/internal/sdk/models/operations/listportalsinternal.go deleted file mode 100644 index a99fa91..0000000 --- a/internal/sdk/models/operations/listportalsinternal.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ListPortalsInternalRequest struct { - Fields []string `queryParam:"style=form,explode=false,name=fields"` - From *float64 `default:"0" queryParam:"style=form,explode=true,name=from"` - Size *float64 `default:"25" queryParam:"style=form,explode=true,name=size"` -} - -func (l ListPortalsInternalRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(l, "", false) -} - -func (l *ListPortalsInternalRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ListPortalsInternalRequest) GetFields() []string { - if o == nil { - return nil - } - return o.Fields -} - -func (o *ListPortalsInternalRequest) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *ListPortalsInternalRequest) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -// ListPortalsInternalResponseBody - List of portals -type ListPortalsInternalResponseBody struct { - // Total number of portals for pagination - Hits *float64 `json:"hits,omitempty"` - Results []shared.PortalConfig `json:"results,omitempty"` -} - -func (o *ListPortalsInternalResponseBody) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *ListPortalsInternalResponseBody) GetResults() []shared.PortalConfig { - if o == nil { - return nil - } - return o.Results -} - -type ListPortalsInternalResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // List of portals - Object *ListPortalsInternalResponseBody -} - -func (o *ListPortalsInternalResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ListPortalsInternalResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ListPortalsInternalResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ListPortalsInternalResponse) GetObject() *ListPortalsInternalResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/logintoportalasuser.go b/internal/sdk/models/operations/logintoportalasuser.go deleted file mode 100644 index c052e49..0000000 --- a/internal/sdk/models/operations/logintoportalasuser.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "net/http" -) - -// LoginToPortalAsUserRequestBody - The request body to log in to a portal impersonating a user -type LoginToPortalAsUserRequestBody struct { - // The email address of the user to log in as - Email *string `json:"email,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` -} - -func (o *LoginToPortalAsUserRequestBody) GetEmail() *string { - if o == nil { - return nil - } - return o.Email -} - -func (o *LoginToPortalAsUserRequestBody) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -// LoginToPortalAsUserResponseBody - The token has been generated successfully. -type LoginToPortalAsUserResponseBody struct { - // A generated login_as_token to log in to a portal impersonating a user. - LoginAsToken *string `json:"login_as_token,omitempty"` -} - -func (o *LoginToPortalAsUserResponseBody) GetLoginAsToken() *string { - if o == nil { - return nil - } - return o.LoginAsToken -} - -type LoginToPortalAsUserResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The token has been generated successfully. - Object *LoginToPortalAsUserResponseBody -} - -func (o *LoginToPortalAsUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *LoginToPortalAsUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *LoginToPortalAsUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *LoginToPortalAsUserResponse) GetObject() *LoginToPortalAsUserResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/notifymlogininterestchange.go b/internal/sdk/models/operations/notifymlogininterestchange.go deleted file mode 100644 index 2647597..0000000 --- a/internal/sdk/models/operations/notifymlogininterestchange.go +++ /dev/null @@ -1,201 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type Resource struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Contact - Contact *string `json:"contact,omitempty"` - // Description - Description *string `json:"description,omitempty"` - // Kind - Kind *string `json:"kind,omitempty"` - // Resource ID - ResourceID *string `json:"resource_id,omitempty"` -} - -func (r Resource) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(r, "", false) -} - -func (r *Resource) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Resource) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Resource) GetContact() *string { - if o == nil { - return nil - } - return o.Contact -} - -func (o *Resource) GetDescription() *string { - if o == nil { - return nil - } - return o.Description -} - -func (o *Resource) GetKind() *string { - if o == nil { - return nil - } - return o.Kind -} - -func (o *Resource) GetResourceID() *string { - if o == nil { - return nil - } - return o.ResourceID -} - -type NotifyMLoginInterestChangeRequestBody struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Action - Action *string `json:"action,omitempty"` - // Interest tag - InterestTag *string `json:"interest_tag,omitempty"` - Resource *Resource `json:"resource,omitempty"` - // Resource ID - ResourceID *string `json:"resource_id,omitempty"` - // Resource type - UserID *string `json:"user_id,omitempty"` -} - -func (n NotifyMLoginInterestChangeRequestBody) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(n, "", false) -} - -func (n *NotifyMLoginInterestChangeRequestBody) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &n, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetAction() *string { - if o == nil { - return nil - } - return o.Action -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetInterestTag() *string { - if o == nil { - return nil - } - return o.InterestTag -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetResource() *Resource { - if o == nil { - return nil - } - return o.Resource -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetResourceID() *string { - if o == nil { - return nil - } - return o.ResourceID -} - -func (o *NotifyMLoginInterestChangeRequestBody) GetUserID() *string { - if o == nil { - return nil - } - return o.UserID -} - -type NotifyMLoginInterestChangeRequest struct { - RequestBody NotifyMLoginInterestChangeRequestBody `request:"mediaType=application/json"` - // Client ID - ClientID string `pathParam:"style=simple,explode=false,name=client_id"` - // User ID - UserID string `pathParam:"style=simple,explode=false,name=user_id"` -} - -func (o *NotifyMLoginInterestChangeRequest) GetRequestBody() NotifyMLoginInterestChangeRequestBody { - if o == nil { - return NotifyMLoginInterestChangeRequestBody{} - } - return o.RequestBody -} - -func (o *NotifyMLoginInterestChangeRequest) GetClientID() string { - if o == nil { - return "" - } - return o.ClientID -} - -func (o *NotifyMLoginInterestChangeRequest) GetUserID() string { - if o == nil { - return "" - } - return o.UserID -} - -type NotifyMLoginInterestChangeResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *NotifyMLoginInterestChangeResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *NotifyMLoginInterestChangeResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *NotifyMLoginInterestChangeResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *NotifyMLoginInterestChangeResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/options.go b/internal/sdk/models/operations/options.go index 32cef5e..0f20c26 100644 --- a/internal/sdk/models/operations/options.go +++ b/internal/sdk/models/operations/options.go @@ -18,12 +18,24 @@ const ( SupportedOptionURLOverride = "urlOverride" ) +type AcceptHeaderEnum string + +const ( + AcceptHeaderEnumApplicationJson AcceptHeaderEnum = "application/json" + AcceptHeaderEnumWildcardRootWildcard AcceptHeaderEnum = "*/*" +) + +func (e AcceptHeaderEnum) ToPointer() *AcceptHeaderEnum { + return &e +} + type Options struct { - ServerURL *string - Retries *retry.Config - Timeout *time.Duration - URLOverride *string - SetHeaders map[string]string + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + AcceptHeaderOverride *AcceptHeaderEnum + URLOverride *string + SetHeaders map[string]string } type Option func(*Options, ...string) error @@ -72,6 +84,17 @@ func WithOperationTimeout(timeout time.Duration) Option { } } +func WithAcceptHeaderOverride(acceptHeaderOverride AcceptHeaderEnum) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionAcceptHeaderOverride) { + return ErrUnsupportedOption + } + + opts.AcceptHeaderOverride = &acceptHeaderOverride + return nil + } +} + // WithURLOverride allows overriding the URL. func WithURLOverride(urlOverride string) Option { return func(opts *Options, supportedOptions ...string) error { diff --git a/internal/sdk/models/operations/postorderacceptance.go b/internal/sdk/models/operations/postorderacceptance.go deleted file mode 100644 index f84aaa3..0000000 --- a/internal/sdk/models/operations/postorderacceptance.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type PostOrderAcceptanceRequest struct { - AcceptanceDecision *shared.AcceptanceDecision `request:"mediaType=application/json"` - // The ID of order - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *PostOrderAcceptanceRequest) GetAcceptanceDecision() *shared.AcceptanceDecision { - if o == nil { - return nil - } - return o.AcceptanceDecision -} - -func (o *PostOrderAcceptanceRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// PostOrderAcceptanceResponseBody - Order was accepted/declined successfully. -type PostOrderAcceptanceResponseBody struct { - // The order entity - Data *shared.Order `json:"data,omitempty"` -} - -func (o *PostOrderAcceptanceResponseBody) GetData() *shared.Order { - if o == nil { - return nil - } - return o.Data -} - -type PostOrderAcceptanceResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Order was accepted/declined successfully. - Object *PostOrderAcceptanceResponseBody -} - -func (o *PostOrderAcceptanceResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *PostOrderAcceptanceResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *PostOrderAcceptanceResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *PostOrderAcceptanceResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *PostOrderAcceptanceResponse) GetObject() *PostOrderAcceptanceResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/putportalconfig.go b/internal/sdk/models/operations/putportalconfig.go deleted file mode 100644 index f60a3ae..0000000 --- a/internal/sdk/models/operations/putportalconfig.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type PutPortalConfigRequest struct { - // Portal configuration payload - PortalConfigV3 shared.PortalConfigV3 `request:"mediaType=application/json"` - // Portal ID (readonly UUID generated on portal creation) - PortalID string `pathParam:"style=simple,explode=false,name=portal_id"` -} - -func (o *PutPortalConfigRequest) GetPortalConfigV3() shared.PortalConfigV3 { - if o == nil { - return shared.PortalConfigV3{} - } - return o.PortalConfigV3 -} - -func (o *PutPortalConfigRequest) GetPortalID() string { - if o == nil { - return "" - } - return o.PortalID -} - -type PutPortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // Portal config updated successfully. - PortalConfigV3 *shared.PortalConfigV3 - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *PutPortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *PutPortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *PutPortalConfigResponse) GetPortalConfigV3() *shared.PortalConfigV3 { - if o == nil { - return nil - } - return o.PortalConfigV3 -} - -func (o *PutPortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *PutPortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/putrole.go b/internal/sdk/models/operations/putrole.go new file mode 100644 index 0000000..30bdd42 --- /dev/null +++ b/internal/sdk/models/operations/putrole.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +type PutRoleRequest struct { + RolePayload *shared.RolePayload `request:"mediaType=application/json"` + RoleID string `pathParam:"style=simple,explode=false,name=roleId"` +} + +func (p *PutRoleRequest) GetRolePayload() *shared.RolePayload { + if p == nil { + return nil + } + return p.RolePayload +} + +func (p *PutRoleRequest) GetRoleID() string { + if p == nil { + return "" + } + return p.RoleID +} + +type PutRoleResponse struct { + // HTTP response content type for this operation + ContentType string + // ok + Role *shared.Role + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (p *PutRoleResponse) GetContentType() string { + if p == nil { + return "" + } + return p.ContentType +} + +func (p *PutRoleResponse) GetRole() *shared.Role { + if p == nil { + return nil + } + return p.Role +} + +func (p *PutRoleResponse) GetStatusCode() int { + if p == nil { + return 0 + } + return p.StatusCode +} + +func (p *PutRoleResponse) GetRawResponse() *http.Response { + if p == nil { + return nil + } + return p.RawResponse +} diff --git a/internal/sdk/models/operations/refreshpermissions.go b/internal/sdk/models/operations/refreshpermissions.go new file mode 100644 index 0000000..b4f2141 --- /dev/null +++ b/internal/sdk/models/operations/refreshpermissions.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "net/http" +) + +type RefreshPermissionsResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (r *RefreshPermissionsResponse) GetContentType() string { + if r == nil { + return "" + } + return r.ContentType +} + +func (r *RefreshPermissionsResponse) GetStatusCode() int { + if r == nil { + return 0 + } + return r.StatusCode +} + +func (r *RefreshPermissionsResponse) GetRawResponse() *http.Response { + if r == nil { + return nil + } + return r.RawResponse +} diff --git a/internal/sdk/models/operations/removeassignment.go b/internal/sdk/models/operations/removeassignment.go new file mode 100644 index 0000000..c03dd79 --- /dev/null +++ b/internal/sdk/models/operations/removeassignment.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +type RemoveAssignmentRequest struct { + RoleID string `pathParam:"style=simple,explode=false,name=roleId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (r *RemoveAssignmentRequest) GetRoleID() string { + if r == nil { + return "" + } + return r.RoleID +} + +func (r *RemoveAssignmentRequest) GetUserID() string { + if r == nil { + return "" + } + return r.UserID +} + +type RemoveAssignmentResponse struct { + // ok + Assignment *shared.Assignment + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response +} + +func (r *RemoveAssignmentResponse) GetAssignment() *shared.Assignment { + if r == nil { + return nil + } + return r.Assignment +} + +func (r *RemoveAssignmentResponse) GetContentType() string { + if r == nil { + return "" + } + return r.ContentType +} + +func (r *RemoveAssignmentResponse) GetStatusCode() int { + if r == nil { + return 0 + } + return r.StatusCode +} + +func (r *RemoveAssignmentResponse) GetRawResponse() *http.Response { + if r == nil { + return nil + } + return r.RawResponse +} diff --git a/internal/sdk/models/operations/replaceecptemplatevariables.go b/internal/sdk/models/operations/replaceecptemplatevariables.go deleted file mode 100644 index d902518..0000000 --- a/internal/sdk/models/operations/replaceecptemplatevariables.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type RequestBody struct { - // Entity ID - ID *string `json:"_id,omitempty"` - IsMainEntity *bool `json:"is_main_entity,omitempty"` -} - -func (o *RequestBody) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *RequestBody) GetIsMainEntity() *bool { - if o == nil { - return nil - } - return o.IsMainEntity -} - -type CustomerPortal struct { - EntityLink *string `json:"entityLink,omitempty"` - InvitationLink *string `json:"invitationLink,omitempty"` - NewDocumentLink *string `json:"newDocumentLink,omitempty"` - UserEmailsOnEntity []string `json:"userEmailsOnEntity,omitempty"` -} - -func (o *CustomerPortal) GetEntityLink() *string { - if o == nil { - return nil - } - return o.EntityLink -} - -func (o *CustomerPortal) GetInvitationLink() *string { - if o == nil { - return nil - } - return o.InvitationLink -} - -func (o *CustomerPortal) GetNewDocumentLink() *string { - if o == nil { - return nil - } - return o.NewDocumentLink -} - -func (o *CustomerPortal) GetUserEmailsOnEntity() []string { - if o == nil { - return nil - } - return o.UserEmailsOnEntity -} - -type InstallerPortal struct { - EntityLink *string `json:"entityLink,omitempty"` - InvitationLink *string `json:"invitationLink,omitempty"` - NewDocumentLink *string `json:"newDocumentLink,omitempty"` - UserEmailsOnEntity []string `json:"userEmailsOnEntity,omitempty"` -} - -func (o *InstallerPortal) GetEntityLink() *string { - if o == nil { - return nil - } - return o.EntityLink -} - -func (o *InstallerPortal) GetInvitationLink() *string { - if o == nil { - return nil - } - return o.InvitationLink -} - -func (o *InstallerPortal) GetNewDocumentLink() *string { - if o == nil { - return nil - } - return o.NewDocumentLink -} - -func (o *InstallerPortal) GetUserEmailsOnEntity() []string { - if o == nil { - return nil - } - return o.UserEmailsOnEntity -} - -// ReplaceECPTemplateVariablesResponseBody - Replaced portal template variables successfully. -type ReplaceECPTemplateVariablesResponseBody struct { - CustomerPortal *CustomerPortal `json:"customerPortal,omitempty"` - InstallerPortal *InstallerPortal `json:"installerPortal,omitempty"` -} - -func (o *ReplaceECPTemplateVariablesResponseBody) GetCustomerPortal() *CustomerPortal { - if o == nil { - return nil - } - return o.CustomerPortal -} - -func (o *ReplaceECPTemplateVariablesResponseBody) GetInstallerPortal() *InstallerPortal { - if o == nil { - return nil - } - return o.InstallerPortal -} - -type ReplaceECPTemplateVariablesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Replaced portal template variables successfully. - Object *ReplaceECPTemplateVariablesResponseBody -} - -func (o *ReplaceECPTemplateVariablesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ReplaceECPTemplateVariablesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ReplaceECPTemplateVariablesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ReplaceECPTemplateVariablesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ReplaceECPTemplateVariablesResponse) GetObject() *ReplaceECPTemplateVariablesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/resendconfirmationemail.go b/internal/sdk/models/operations/resendconfirmationemail.go deleted file mode 100644 index 6eddaa7..0000000 --- a/internal/sdk/models/operations/resendconfirmationemail.go +++ /dev/null @@ -1,105 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ResendConfirmationEmailRequest struct { - // The ID of portal user id - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *ResendConfirmationEmailRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type Message string - -const ( - MessageConfirmationEmailSentSuccessfully Message = "Confirmation email sent successfully." -) - -func (e Message) ToPointer() *Message { - return &e -} -func (e *Message) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "Confirmation email sent successfully.": - *e = Message(v) - return nil - default: - return fmt.Errorf("invalid value for Message: %v", v) - } -} - -// ResendConfirmationEmailResponseBody - Confirmation email resent successfully for the portal user. -type ResendConfirmationEmailResponseBody struct { - Message *Message `json:"message,omitempty"` -} - -func (o *ResendConfirmationEmailResponseBody) GetMessage() *Message { - if o == nil { - return nil - } - return o.Message -} - -type ResendConfirmationEmailResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Confirmation email resent successfully for the portal user. - Object *ResendConfirmationEmailResponseBody -} - -func (o *ResendConfirmationEmailResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ResendConfirmationEmailResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ResendConfirmationEmailResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ResendConfirmationEmailResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ResendConfirmationEmailResponse) GetObject() *ResendConfirmationEmailResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/revoketoken.go b/internal/sdk/models/operations/revoketoken.go deleted file mode 100644 index fdfb064..0000000 --- a/internal/sdk/models/operations/revoketoken.go +++ /dev/null @@ -1,106 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// RevokeTokenRequestBody - Token payload -type RevokeTokenRequestBody struct { - // Refresh Token to be revoked - RefreshToken string `json:"refresh_token"` -} - -func (o *RevokeTokenRequestBody) GetRefreshToken() string { - if o == nil { - return "" - } - return o.RefreshToken -} - -type RevokeTokenMessage string - -const ( - RevokeTokenMessageTokenRevokedSuccessfully RevokeTokenMessage = "Token revoked successfully" -) - -func (e RevokeTokenMessage) ToPointer() *RevokeTokenMessage { - return &e -} -func (e *RevokeTokenMessage) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "Token revoked successfully": - *e = RevokeTokenMessage(v) - return nil - default: - return fmt.Errorf("invalid value for RevokeTokenMessage: %v", v) - } -} - -// RevokeTokenResponseBody - Access Tokens revoked successfully for the given Refresh Token. -type RevokeTokenResponseBody struct { - Message *RevokeTokenMessage `json:"message,omitempty"` -} - -func (o *RevokeTokenResponseBody) GetMessage() *RevokeTokenMessage { - if o == nil { - return nil - } - return o.Message -} - -type RevokeTokenResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Access Tokens revoked successfully for the given Refresh Token. - Object *RevokeTokenResponseBody -} - -func (o *RevokeTokenResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *RevokeTokenResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *RevokeTokenResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *RevokeTokenResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *RevokeTokenResponse) GetObject() *RevokeTokenResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/saveentityfile.go b/internal/sdk/models/operations/saveentityfile.go deleted file mode 100644 index 5a0cd5c..0000000 --- a/internal/sdk/models/operations/saveentityfile.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// SaveEntityFileResponseBody - The files have been saved to the entitiy successfully. -type SaveEntityFileResponseBody struct { - CreatedFiles []shared.File `json:"createdFiles,omitempty"` -} - -func (o *SaveEntityFileResponseBody) GetCreatedFiles() []shared.File { - if o == nil { - return nil - } - return o.CreatedFiles -} - -type SaveEntityFileResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The files have been saved to the entitiy successfully. - Object *SaveEntityFileResponseBody -} - -func (o *SaveEntityFileResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SaveEntityFileResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SaveEntityFileResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SaveEntityFileResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SaveEntityFileResponse) GetObject() *SaveEntityFileResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/saveportalfiles.go b/internal/sdk/models/operations/saveportalfiles.go deleted file mode 100644 index 82df1e5..0000000 --- a/internal/sdk/models/operations/saveportalfiles.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// SavePortalFilesResponseBody - The files have been saved to the portal successfully. -type SavePortalFilesResponseBody struct { - CreatedFiles []shared.File `json:"createdFiles,omitempty"` -} - -func (o *SavePortalFilesResponseBody) GetCreatedFiles() []shared.File { - if o == nil { - return nil - } - return o.CreatedFiles -} - -type SavePortalFilesResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The files have been saved to the portal successfully. - Object *SavePortalFilesResponseBody -} - -func (o *SavePortalFilesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SavePortalFilesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SavePortalFilesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SavePortalFilesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SavePortalFilesResponse) GetObject() *SavePortalFilesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/searchpaymentrelationsinentities.go b/internal/sdk/models/operations/searchpaymentrelationsinentities.go deleted file mode 100644 index 9495aed..0000000 --- a/internal/sdk/models/operations/searchpaymentrelationsinentities.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type SearchPaymentRelationsInEntitiesRequest struct { - // Entity id - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *SearchPaymentRelationsInEntitiesRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// SearchPaymentRelationsInEntitiesResponseBody - Entities that have the payment relation. -type SearchPaymentRelationsInEntitiesResponseBody struct { - // Total number of files for entities found - Hits *float64 `json:"hits,omitempty"` - Results []shared.EntityItem `json:"results,omitempty"` -} - -func (o *SearchPaymentRelationsInEntitiesResponseBody) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *SearchPaymentRelationsInEntitiesResponseBody) GetResults() []shared.EntityItem { - if o == nil { - return nil - } - return o.Results -} - -type SearchPaymentRelationsInEntitiesResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Entities that have the payment relation. - Object *SearchPaymentRelationsInEntitiesResponseBody -} - -func (o *SearchPaymentRelationsInEntitiesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SearchPaymentRelationsInEntitiesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SearchPaymentRelationsInEntitiesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SearchPaymentRelationsInEntitiesResponse) GetObject() *SearchPaymentRelationsInEntitiesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/searchportaluserentities.go b/internal/sdk/models/operations/searchportaluserentities.go deleted file mode 100644 index 914eed2..0000000 --- a/internal/sdk/models/operations/searchportaluserentities.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type SearchPortalUserEntitiesResponseBodyType string - -const ( - SearchPortalUserEntitiesResponseBodyTypeEntityResponseWithHits SearchPortalUserEntitiesResponseBodyType = "EntityResponseWithHits" - SearchPortalUserEntitiesResponseBodyTypeEntityResponseGroupedWithHits SearchPortalUserEntitiesResponseBodyType = "EntityResponseGroupedWithHits" -) - -// SearchPortalUserEntitiesResponseBody - The entities have been retrieved successfully for the portal user. -type SearchPortalUserEntitiesResponseBody struct { - EntityResponseWithHits *shared.EntityResponseWithHits `queryParam:"inline" name:"responseBody"` - EntityResponseGroupedWithHits *shared.EntityResponseGroupedWithHits `queryParam:"inline" name:"responseBody"` - - Type SearchPortalUserEntitiesResponseBodyType -} - -func CreateSearchPortalUserEntitiesResponseBodyEntityResponseWithHits(entityResponseWithHits shared.EntityResponseWithHits) SearchPortalUserEntitiesResponseBody { - typ := SearchPortalUserEntitiesResponseBodyTypeEntityResponseWithHits - - return SearchPortalUserEntitiesResponseBody{ - EntityResponseWithHits: &entityResponseWithHits, - Type: typ, - } -} - -func CreateSearchPortalUserEntitiesResponseBodyEntityResponseGroupedWithHits(entityResponseGroupedWithHits shared.EntityResponseGroupedWithHits) SearchPortalUserEntitiesResponseBody { - typ := SearchPortalUserEntitiesResponseBodyTypeEntityResponseGroupedWithHits - - return SearchPortalUserEntitiesResponseBody{ - EntityResponseGroupedWithHits: &entityResponseGroupedWithHits, - Type: typ, - } -} - -func (u *SearchPortalUserEntitiesResponseBody) UnmarshalJSON(data []byte) error { - - var entityResponseWithHits shared.EntityResponseWithHits = shared.EntityResponseWithHits{} - if err := utils.UnmarshalJSON(data, &entityResponseWithHits, "", true, nil); err == nil { - u.EntityResponseWithHits = &entityResponseWithHits - u.Type = SearchPortalUserEntitiesResponseBodyTypeEntityResponseWithHits - return nil - } - - var entityResponseGroupedWithHits shared.EntityResponseGroupedWithHits = shared.EntityResponseGroupedWithHits{} - if err := utils.UnmarshalJSON(data, &entityResponseGroupedWithHits, "", true, nil); err == nil { - u.EntityResponseGroupedWithHits = &entityResponseGroupedWithHits - u.Type = SearchPortalUserEntitiesResponseBodyTypeEntityResponseGroupedWithHits - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for SearchPortalUserEntitiesResponseBody", string(data)) -} - -func (u SearchPortalUserEntitiesResponseBody) MarshalJSON() ([]byte, error) { - if u.EntityResponseWithHits != nil { - return utils.MarshalJSON(u.EntityResponseWithHits, "", true) - } - - if u.EntityResponseGroupedWithHits != nil { - return utils.MarshalJSON(u.EntityResponseGroupedWithHits, "", true) - } - - return nil, errors.New("could not marshal union type SearchPortalUserEntitiesResponseBody: all fields are null") -} - -type SearchPortalUserEntitiesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The entities have been retrieved successfully for the portal user. - OneOf *SearchPortalUserEntitiesResponseBody -} - -func (o *SearchPortalUserEntitiesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SearchPortalUserEntitiesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SearchPortalUserEntitiesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SearchPortalUserEntitiesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SearchPortalUserEntitiesResponse) GetOneOf() *SearchPortalUserEntitiesResponseBody { - if o == nil { - return nil - } - return o.OneOf -} diff --git a/internal/sdk/models/operations/searchroles.go b/internal/sdk/models/operations/searchroles.go new file mode 100644 index 0000000..f56e0ab --- /dev/null +++ b/internal/sdk/models/operations/searchroles.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "net/http" +) + +// SearchRolesResponseBody - ok +type SearchRolesResponseBody struct { + Hits *float64 `json:"hits,omitempty"` + Results []shared.Role `json:"results,omitempty"` +} + +func (s *SearchRolesResponseBody) GetHits() *float64 { + if s == nil { + return nil + } + return s.Hits +} + +func (s *SearchRolesResponseBody) GetResults() []shared.Role { + if s == nil { + return nil + } + return s.Results +} + +type SearchRolesResponse struct { + // HTTP response content type for this operation + ContentType string + // HTTP response status code for this operation + StatusCode int + // Raw HTTP response; suitable for custom response parsing + RawResponse *http.Response + // ok + Object *SearchRolesResponseBody +} + +func (s *SearchRolesResponse) GetContentType() string { + if s == nil { + return "" + } + return s.ContentType +} + +func (s *SearchRolesResponse) GetStatusCode() int { + if s == nil { + return 0 + } + return s.StatusCode +} + +func (s *SearchRolesResponse) GetRawResponse() *http.Response { + if s == nil { + return nil + } + return s.RawResponse +} + +func (s *SearchRolesResponse) GetObject() *SearchRolesResponseBody { + if s == nil { + return nil + } + return s.Object +} diff --git a/internal/sdk/models/operations/ssocallback.go b/internal/sdk/models/operations/ssocallback.go deleted file mode 100644 index fbcaae7..0000000 --- a/internal/sdk/models/operations/ssocallback.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type SsoCallbackRequest struct { - SSOCallbackRequest shared.SSOCallbackRequest `request:"mediaType=application/json"` - Domain *string `queryParam:"style=form,explode=true,name=domain"` -} - -func (o *SsoCallbackRequest) GetSSOCallbackRequest() shared.SSOCallbackRequest { - if o == nil { - return shared.SSOCallbackRequest{} - } - return o.SSOCallbackRequest -} - -func (o *SsoCallbackRequest) GetDomain() *string { - if o == nil { - return nil - } - return o.Domain -} - -type SsoCallbackResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // The token to be used with the CUSTOM_AUTH flow against Cognito - SSOCallbackResponse *shared.SSOCallbackResponse - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *SsoCallbackResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SsoCallbackResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SsoCallbackResponse) GetSSOCallbackResponse() *shared.SSOCallbackResponse { - if o == nil { - return nil - } - return o.SSOCallbackResponse -} - -func (o *SsoCallbackResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SsoCallbackResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/ssologin.go b/internal/sdk/models/operations/ssologin.go deleted file mode 100644 index 29f1ab2..0000000 --- a/internal/sdk/models/operations/ssologin.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "net/http" -) - -type SsoLoginSecurity struct { - ExternalOIDCAuth string `security:"scheme,type=http,subtype=bearer,name=Authorization"` -} - -func (o *SsoLoginSecurity) GetExternalOIDCAuth() string { - if o == nil { - return "" - } - return o.ExternalOIDCAuth -} - -type SsoLoginRequestBody struct { - // URL-friendly slug to use as organization-unique identifier for Provider - ProviderSlug *string `json:"provider_slug,omitempty"` -} - -func (o *SsoLoginRequestBody) GetProviderSlug() *string { - if o == nil { - return nil - } - return o.ProviderSlug -} - -type SsoLoginRequest struct { - RequestBody *SsoLoginRequestBody `request:"mediaType=application/json"` - // contact id in the epilot system - ContactID *string `queryParam:"style=form,explode=true,name=contact_id"` - // epilot organization id - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - // Origin of the Portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *SsoLoginRequest) GetRequestBody() *SsoLoginRequestBody { - if o == nil { - return nil - } - return o.RequestBody -} - -func (o *SsoLoginRequest) GetContactID() *string { - if o == nil { - return nil - } - return o.ContactID -} - -func (o *SsoLoginRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *SsoLoginRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -// SsoLoginResponseBody - Cognito login parameters to use with the CUSTOM_AUTH_FLOW -type SsoLoginResponseBody struct { - // The email address of the user to log in as - Email *string `json:"email,omitempty"` - Token *string `json:"token,omitempty"` -} - -func (o *SsoLoginResponseBody) GetEmail() *string { - if o == nil { - return nil - } - return o.Email -} - -func (o *SsoLoginResponseBody) GetToken() *string { - if o == nil { - return nil - } - return o.Token -} - -type SsoLoginResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Cognito login parameters to use with the CUSTOM_AUTH_FLOW - Object *SsoLoginResponseBody -} - -func (o *SsoLoginResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SsoLoginResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SsoLoginResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SsoLoginResponse) GetObject() *SsoLoginResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/ssoredirect.go b/internal/sdk/models/operations/ssoredirect.go deleted file mode 100644 index 0973e01..0000000 --- a/internal/sdk/models/operations/ssoredirect.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type SsoRedirectRequestBody struct { - // The code received from the external SSO provider - Code *string `multipartForm:"name=code"` - // The state received from the external SSO provider - State *string `multipartForm:"name=state"` -} - -func (o *SsoRedirectRequestBody) GetCode() *string { - if o == nil { - return nil - } - return o.Code -} - -func (o *SsoRedirectRequestBody) GetState() *string { - if o == nil { - return nil - } - return o.State -} - -type SsoRedirectRequest struct { - RequestBody SsoRedirectRequestBody `request:"mediaType=multipart/form-data"` - // The URI to redirect to after the SSO login - WebURI string `queryParam:"style=form,explode=true,name=web_uri"` -} - -func (o *SsoRedirectRequest) GetRequestBody() SsoRedirectRequestBody { - if o == nil { - return SsoRedirectRequestBody{} - } - return o.RequestBody -} - -func (o *SsoRedirectRequest) GetWebURI() string { - if o == nil { - return "" - } - return o.WebURI -} - -type SsoRedirectResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - Headers map[string][]string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *SsoRedirectResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SsoRedirectResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SsoRedirectResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} - -func (o *SsoRedirectResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SsoRedirectResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/swapportalconfig.go b/internal/sdk/models/operations/swapportalconfig.go deleted file mode 100644 index eda8ee5..0000000 --- a/internal/sdk/models/operations/swapportalconfig.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// SwapPortalConfigRequestBody - Source and target portal IDs -type SwapPortalConfigRequestBody struct { - // Items to swap - ItemsToSwap []shared.SwappableConfig `json:"items_to_swap,omitempty"` - // Source portal ID - SourcePortalID string `json:"source_portal_id"` - // Target portal ID - TargetPortalID string `json:"target_portal_id"` -} - -func (o *SwapPortalConfigRequestBody) GetItemsToSwap() []shared.SwappableConfig { - if o == nil { - return nil - } - return o.ItemsToSwap -} - -func (o *SwapPortalConfigRequestBody) GetSourcePortalID() string { - if o == nil { - return "" - } - return o.SourcePortalID -} - -func (o *SwapPortalConfigRequestBody) GetTargetPortalID() string { - if o == nil { - return "" - } - return o.TargetPortalID -} - -// SwapPortalConfigResponseBody - Domain and users swapped successfully. -type SwapPortalConfigResponseBody struct { - Message *string `json:"message,omitempty"` -} - -func (o *SwapPortalConfigResponseBody) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} - -type SwapPortalConfigResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Domain and users swapped successfully. - Object *SwapPortalConfigResponseBody -} - -func (o *SwapPortalConfigResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *SwapPortalConfigResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *SwapPortalConfigResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *SwapPortalConfigResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *SwapPortalConfigResponse) GetObject() *SwapPortalConfigResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/trackfiledownloaded.go b/internal/sdk/models/operations/trackfiledownloaded.go deleted file mode 100644 index a91efd3..0000000 --- a/internal/sdk/models/operations/trackfiledownloaded.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type TrackFileDownloadedRequest struct { - // The Id of a file - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *TrackFileDownloadedRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// TrackFileDownloadedResponseBody - File download tracked successfully. -type TrackFileDownloadedResponseBody struct { - File *shared.FileItem `json:"file,omitempty"` -} - -func (o *TrackFileDownloadedResponseBody) GetFile() *shared.FileItem { - if o == nil { - return nil - } - return o.File -} - -type TrackFileDownloadedResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // File download tracked successfully. - Object *TrackFileDownloadedResponseBody -} - -func (o *TrackFileDownloadedResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *TrackFileDownloadedResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *TrackFileDownloadedResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *TrackFileDownloadedResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *TrackFileDownloadedResponse) GetObject() *TrackFileDownloadedResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/triggerentityaccessevent.go b/internal/sdk/models/operations/triggerentityaccessevent.go deleted file mode 100644 index 6dda1f1..0000000 --- a/internal/sdk/models/operations/triggerentityaccessevent.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "net/http" -) - -type TriggerEntityAccessEventRequest struct { - // Entity ID - EntityID *string `queryParam:"style=form,explode=true,name=entity_id"` - // Portal origin - Origin string `queryParam:"style=form,explode=true,name=origin"` - // Entity schema - Schema string `pathParam:"style=simple,explode=false,name=schema"` -} - -func (o *TriggerEntityAccessEventRequest) GetEntityID() *string { - if o == nil { - return nil - } - return o.EntityID -} - -func (o *TriggerEntityAccessEventRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -func (o *TriggerEntityAccessEventRequest) GetSchema() string { - if o == nil { - return "" - } - return o.Schema -} - -// TriggerEntityAccessEventResponseBody - The event has been triggered successfully. -type TriggerEntityAccessEventResponseBody struct { - // Event ID - EventID *string `json:"eventId,omitempty"` -} - -func (o *TriggerEntityAccessEventResponseBody) GetEventID() *string { - if o == nil { - return nil - } - return o.EventID -} - -type TriggerEntityAccessEventResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The event has been triggered successfully. - Object *TriggerEntityAccessEventResponseBody -} - -func (o *TriggerEntityAccessEventResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *TriggerEntityAccessEventResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *TriggerEntityAccessEventResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *TriggerEntityAccessEventResponse) GetObject() *TriggerEntityAccessEventResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updatecampaignportalblockstatus.go b/internal/sdk/models/operations/updatecampaignportalblockstatus.go deleted file mode 100644 index dff9a0f..0000000 --- a/internal/sdk/models/operations/updatecampaignportalblockstatus.go +++ /dev/null @@ -1,190 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type EntityRefs struct { - // Entity ID - EntityID string `json:"entity_id"` - // Schema of the entity (e.g., contact, contract, opportunity, order, meter) - EntitySchema string `json:"entity_schema"` -} - -func (o *EntityRefs) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *EntityRefs) GetEntitySchema() string { - if o == nil { - return "" - } - return o.EntitySchema -} - -// Status - The status to set for the campaign portal block -type Status string - -const ( - StatusSeen Status = "seen" - StatusDismissed Status = "dismissed" - StatusClicked Status = "clicked" -) - -func (e Status) ToPointer() *Status { - return &e -} -func (e *Status) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "seen": - fallthrough - case "dismissed": - fallthrough - case "clicked": - *e = Status(v) - return nil - default: - return fmt.Errorf("invalid value for Status: %v", v) - } -} - -type UpdateCampaignPortalBlockStatusRequestBody struct { - // Array of entity references with their schemas - EntityRefs []EntityRefs `json:"entity_refs"` - // The status to set for the campaign portal block - Status Status `json:"status"` -} - -func (o *UpdateCampaignPortalBlockStatusRequestBody) GetEntityRefs() []EntityRefs { - if o == nil { - return []EntityRefs{} - } - return o.EntityRefs -} - -func (o *UpdateCampaignPortalBlockStatusRequestBody) GetStatus() Status { - if o == nil { - return Status("") - } - return o.Status -} - -type UpdateCampaignPortalBlockStatusRequest struct { - RequestBody UpdateCampaignPortalBlockStatusRequestBody `request:"mediaType=application/json"` - // ID of the campaign - CampaignID string `pathParam:"style=simple,explode=false,name=campaign_id"` -} - -func (o *UpdateCampaignPortalBlockStatusRequest) GetRequestBody() UpdateCampaignPortalBlockStatusRequestBody { - if o == nil { - return UpdateCampaignPortalBlockStatusRequestBody{} - } - return o.RequestBody -} - -func (o *UpdateCampaignPortalBlockStatusRequest) GetCampaignID() string { - if o == nil { - return "" - } - return o.CampaignID -} - -// UpdateCampaignPortalBlockStatusResponseBody - Campaign portal block status updated successfully. -type UpdateCampaignPortalBlockStatusResponseBody struct { - // Number of entities that failed to update - Failed int64 `json:"failed"` - // Whether the operation completed successfully - Success bool `json:"success"` - // Total number of entities processed - Total int64 `json:"total"` - // Number of entities successfully updated - Updated int64 `json:"updated"` -} - -func (o *UpdateCampaignPortalBlockStatusResponseBody) GetFailed() int64 { - if o == nil { - return 0 - } - return o.Failed -} - -func (o *UpdateCampaignPortalBlockStatusResponseBody) GetSuccess() bool { - if o == nil { - return false - } - return o.Success -} - -func (o *UpdateCampaignPortalBlockStatusResponseBody) GetTotal() int64 { - if o == nil { - return 0 - } - return o.Total -} - -func (o *UpdateCampaignPortalBlockStatusResponseBody) GetUpdated() int64 { - if o == nil { - return 0 - } - return o.Updated -} - -type UpdateCampaignPortalBlockStatusResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Campaign portal block status updated successfully. - Object *UpdateCampaignPortalBlockStatusResponseBody -} - -func (o *UpdateCampaignPortalBlockStatusResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateCampaignPortalBlockStatusResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdateCampaignPortalBlockStatusResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateCampaignPortalBlockStatusResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateCampaignPortalBlockStatusResponse) GetObject() *UpdateCampaignPortalBlockStatusResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updatecontact.go b/internal/sdk/models/operations/updatecontact.go deleted file mode 100644 index 3fa3681..0000000 --- a/internal/sdk/models/operations/updatecontact.go +++ /dev/null @@ -1,145 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdateContactECPResponseBodyType string - -const ( - UpdateContactECPResponseBodyTypeErrorResp UpdateContactECPResponseBodyType = "ErrorResp" - UpdateContactECPResponseBodyTypeFailedRuleErrorResp UpdateContactECPResponseBodyType = "FailedRuleErrorResp" -) - -// UpdateContactECPResponseBody - The user is not allowed to access this resource -type UpdateContactECPResponseBody struct { - ErrorResp *shared.ErrorResp `queryParam:"inline" name:"responseBody"` - FailedRuleErrorResp *shared.FailedRuleErrorResp `queryParam:"inline" name:"responseBody"` - - Type UpdateContactECPResponseBodyType -} - -func CreateUpdateContactECPResponseBodyErrorResp(errorResp shared.ErrorResp) UpdateContactECPResponseBody { - typ := UpdateContactECPResponseBodyTypeErrorResp - - return UpdateContactECPResponseBody{ - ErrorResp: &errorResp, - Type: typ, - } -} - -func CreateUpdateContactECPResponseBodyFailedRuleErrorResp(failedRuleErrorResp shared.FailedRuleErrorResp) UpdateContactECPResponseBody { - typ := UpdateContactECPResponseBodyTypeFailedRuleErrorResp - - return UpdateContactECPResponseBody{ - FailedRuleErrorResp: &failedRuleErrorResp, - Type: typ, - } -} - -func (u *UpdateContactECPResponseBody) UnmarshalJSON(data []byte) error { - - var errorResp shared.ErrorResp = shared.ErrorResp{} - if err := utils.UnmarshalJSON(data, &errorResp, "", true, nil); err == nil { - u.ErrorResp = &errorResp - u.Type = UpdateContactECPResponseBodyTypeErrorResp - return nil - } - - var failedRuleErrorResp shared.FailedRuleErrorResp = shared.FailedRuleErrorResp{} - if err := utils.UnmarshalJSON(data, &failedRuleErrorResp, "", true, nil); err == nil { - u.FailedRuleErrorResp = &failedRuleErrorResp - u.Type = UpdateContactECPResponseBodyTypeFailedRuleErrorResp - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for UpdateContactECPResponseBody", string(data)) -} - -func (u UpdateContactECPResponseBody) MarshalJSON() ([]byte, error) { - if u.ErrorResp != nil { - return utils.MarshalJSON(u.ErrorResp, "", true) - } - - if u.FailedRuleErrorResp != nil { - return utils.MarshalJSON(u.FailedRuleErrorResp, "", true) - } - - return nil, errors.New("could not marshal union type UpdateContactECPResponseBody: all fields are null") -} - -// UpdateContactResponseBody - Updated the contact details successfully. -type UpdateContactResponseBody struct { - // The mapped contact of the portal user - Data *shared.Contact `json:"data,omitempty"` -} - -func (o *UpdateContactResponseBody) GetData() *shared.Contact { - if o == nil { - return nil - } - return o.Data -} - -type UpdateContactResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Updated the contact details successfully. - Object *UpdateContactResponseBody - // The user is not allowed to access this resource - OneOf *UpdateContactECPResponseBody -} - -func (o *UpdateContactResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateContactResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdateContactResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateContactResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateContactResponse) GetObject() *UpdateContactResponseBody { - if o == nil { - return nil - } - return o.Object -} - -func (o *UpdateContactResponse) GetOneOf() *UpdateContactECPResponseBody { - if o == nil { - return nil - } - return o.OneOf -} diff --git a/internal/sdk/models/operations/updatecontract.go b/internal/sdk/models/operations/updatecontract.go deleted file mode 100644 index 9f65fbe..0000000 --- a/internal/sdk/models/operations/updatecontract.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdateContractRequest struct { - // Requested contract body to update - RequestBody map[string]any `request:"mediaType=application/json"` - // The ID of the contract - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *UpdateContractRequest) GetRequestBody() map[string]any { - if o == nil { - return map[string]any{} - } - return o.RequestBody -} - -func (o *UpdateContractRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type UpdateContractECPResponseBodyType string - -const ( - UpdateContractECPResponseBodyTypeErrorResp UpdateContractECPResponseBodyType = "ErrorResp" - UpdateContractECPResponseBodyTypeFailedRuleErrorResp UpdateContractECPResponseBodyType = "FailedRuleErrorResp" -) - -// UpdateContractECPResponseBody - The user is not allowed to access this resource -type UpdateContractECPResponseBody struct { - ErrorResp *shared.ErrorResp `queryParam:"inline" name:"responseBody"` - FailedRuleErrorResp *shared.FailedRuleErrorResp `queryParam:"inline" name:"responseBody"` - - Type UpdateContractECPResponseBodyType -} - -func CreateUpdateContractECPResponseBodyErrorResp(errorResp shared.ErrorResp) UpdateContractECPResponseBody { - typ := UpdateContractECPResponseBodyTypeErrorResp - - return UpdateContractECPResponseBody{ - ErrorResp: &errorResp, - Type: typ, - } -} - -func CreateUpdateContractECPResponseBodyFailedRuleErrorResp(failedRuleErrorResp shared.FailedRuleErrorResp) UpdateContractECPResponseBody { - typ := UpdateContractECPResponseBodyTypeFailedRuleErrorResp - - return UpdateContractECPResponseBody{ - FailedRuleErrorResp: &failedRuleErrorResp, - Type: typ, - } -} - -func (u *UpdateContractECPResponseBody) UnmarshalJSON(data []byte) error { - - var errorResp shared.ErrorResp = shared.ErrorResp{} - if err := utils.UnmarshalJSON(data, &errorResp, "", true, nil); err == nil { - u.ErrorResp = &errorResp - u.Type = UpdateContractECPResponseBodyTypeErrorResp - return nil - } - - var failedRuleErrorResp shared.FailedRuleErrorResp = shared.FailedRuleErrorResp{} - if err := utils.UnmarshalJSON(data, &failedRuleErrorResp, "", true, nil); err == nil { - u.FailedRuleErrorResp = &failedRuleErrorResp - u.Type = UpdateContractECPResponseBodyTypeFailedRuleErrorResp - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for UpdateContractECPResponseBody", string(data)) -} - -func (u UpdateContractECPResponseBody) MarshalJSON() ([]byte, error) { - if u.ErrorResp != nil { - return utils.MarshalJSON(u.ErrorResp, "", true) - } - - if u.FailedRuleErrorResp != nil { - return utils.MarshalJSON(u.FailedRuleErrorResp, "", true) - } - - return nil, errors.New("could not marshal union type UpdateContractECPResponseBody: all fields are null") -} - -// UpdateContractResponseBody - Updated the contract successfully. -type UpdateContractResponseBody struct { - // The contract entity - Data *shared.Contract `json:"data,omitempty"` -} - -func (o *UpdateContractResponseBody) GetData() *shared.Contract { - if o == nil { - return nil - } - return o.Data -} - -type UpdateContractResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Updated the contract successfully. - Object *UpdateContractResponseBody - // The user is not allowed to access this resource - OneOf *UpdateContractECPResponseBody -} - -func (o *UpdateContractResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateContractResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdateContractResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateContractResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateContractResponse) GetObject() *UpdateContractResponseBody { - if o == nil { - return nil - } - return o.Object -} - -func (o *UpdateContractResponse) GetOneOf() *UpdateContractECPResponseBody { - if o == nil { - return nil - } - return o.OneOf -} diff --git a/internal/sdk/models/operations/updateopportunity.go b/internal/sdk/models/operations/updateopportunity.go deleted file mode 100644 index 814f4da..0000000 --- a/internal/sdk/models/operations/updateopportunity.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdateOpportunityRequest struct { - // Requested opportunity body to update - RequestBody map[string]any `request:"mediaType=application/json"` - // The ID of opportunity - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *UpdateOpportunityRequest) GetRequestBody() map[string]any { - if o == nil { - return map[string]any{} - } - return o.RequestBody -} - -func (o *UpdateOpportunityRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// UpdateOpportunityResponseBody - Updated the opportunity successfully. -type UpdateOpportunityResponseBody struct { - // The opportunity entity - Data *shared.Opportunity `json:"data,omitempty"` -} - -func (o *UpdateOpportunityResponseBody) GetData() *shared.Opportunity { - if o == nil { - return nil - } - return o.Data -} - -type UpdateOpportunityResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Updated the opportunity successfully. - Object *UpdateOpportunityResponseBody -} - -func (o *UpdateOpportunityResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateOpportunityResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdateOpportunityResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateOpportunityResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateOpportunityResponse) GetObject() *UpdateOpportunityResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updateorder.go b/internal/sdk/models/operations/updateorder.go deleted file mode 100644 index 1e25785..0000000 --- a/internal/sdk/models/operations/updateorder.go +++ /dev/null @@ -1,89 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdateOrderRequest struct { - RequestBody map[string]any `request:"mediaType=application/json"` - // The ID of order - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *UpdateOrderRequest) GetRequestBody() map[string]any { - if o == nil { - return nil - } - return o.RequestBody -} - -func (o *UpdateOrderRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -// UpdateOrderResponseBody - Updated the order details successfully. -type UpdateOrderResponseBody struct { - // The order entity - Data *shared.Order `json:"data,omitempty"` -} - -func (o *UpdateOrderResponseBody) GetData() *shared.Order { - if o == nil { - return nil - } - return o.Data -} - -type UpdateOrderResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Updated the order details successfully. - Object *UpdateOrderResponseBody -} - -func (o *UpdateOrderResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateOrderResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdateOrderResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateOrderResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateOrderResponse) GetObject() *UpdateOrderResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updateportalpage.go b/internal/sdk/models/operations/updateportalpage.go deleted file mode 100644 index 9dd4265..0000000 --- a/internal/sdk/models/operations/updateportalpage.go +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdatePortalPageRequest struct { - // The portal page to update - PageRequest shared.PageRequest `request:"mediaType=application/json"` - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *UpdatePortalPageRequest) GetPageRequest() shared.PageRequest { - if o == nil { - return shared.PageRequest{} - } - return o.PageRequest -} - -func (o *UpdatePortalPageRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type UpdatePortalPageResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // The portal page has been fetched successfully. - Page *shared.Page - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *UpdatePortalPageResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdatePortalPageResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdatePortalPageResponse) GetPage() *shared.Page { - if o == nil { - return nil - } - return o.Page -} - -func (o *UpdatePortalPageResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdatePortalPageResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/updateportalpageblock.go b/internal/sdk/models/operations/updateportalpageblock.go deleted file mode 100644 index 3ce78b2..0000000 --- a/internal/sdk/models/operations/updateportalpageblock.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpdatePortalPageBlockRequest struct { - // The portal page block to update - BlockRequest shared.BlockRequest `request:"mediaType=application/json"` - BlockID string `pathParam:"style=simple,explode=false,name=block_id"` - ID string `pathParam:"style=simple,explode=false,name=id"` -} - -func (o *UpdatePortalPageBlockRequest) GetBlockRequest() shared.BlockRequest { - if o == nil { - return shared.BlockRequest{} - } - return o.BlockRequest -} - -func (o *UpdatePortalPageBlockRequest) GetBlockID() string { - if o == nil { - return "" - } - return o.BlockID -} - -func (o *UpdatePortalPageBlockRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -type UpdatePortalPageBlockResponse struct { - // The portal page block has been fetched successfully. - Block *shared.Block - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *UpdatePortalPageBlockResponse) GetBlock() *shared.Block { - if o == nil { - return nil - } - return o.Block -} - -func (o *UpdatePortalPageBlockResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdatePortalPageBlockResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdatePortalPageBlockResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdatePortalPageBlockResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/updateportaluser.go b/internal/sdk/models/operations/updateportaluser.go deleted file mode 100644 index 9e3d035..0000000 --- a/internal/sdk/models/operations/updateportaluser.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// UpdatePortalUserResponseBody - The portal user updated successfully. -type UpdatePortalUserResponseBody struct { - // The portal user entity - Data *shared.PortalUser `json:"data,omitempty"` -} - -func (o *UpdatePortalUserResponseBody) GetData() *shared.PortalUser { - if o == nil { - return nil - } - return o.Data -} - -type UpdatePortalUserResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // The portal user updated successfully. - Object *UpdatePortalUserResponseBody -} - -func (o *UpdatePortalUserResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdatePortalUserResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdatePortalUserResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdatePortalUserResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdatePortalUserResponse) GetObject() *UpdatePortalUserResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updateportaluseremail.go b/internal/sdk/models/operations/updateportaluseremail.go deleted file mode 100644 index bb6afc6..0000000 --- a/internal/sdk/models/operations/updateportaluseremail.go +++ /dev/null @@ -1,115 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// UpdatePortalUserEmailRequestBody - Request payload -type UpdatePortalUserEmailRequestBody struct { - // New email address of the portal user - Email string `json:"email"` - // Password of the portal user for confirmation - Password string `json:"password"` -} - -func (o *UpdatePortalUserEmailRequestBody) GetEmail() string { - if o == nil { - return "" - } - return o.Email -} - -func (o *UpdatePortalUserEmailRequestBody) GetPassword() string { - if o == nil { - return "" - } - return o.Password -} - -type UpdatePortalUserEmailMessage string - -const ( - UpdatePortalUserEmailMessageYouWillReceiveAConfirmationMailSoonOnYourUpdatedEmailAddress UpdatePortalUserEmailMessage = "You will receive a confirmation mail soon on your updated email address." -) - -func (e UpdatePortalUserEmailMessage) ToPointer() *UpdatePortalUserEmailMessage { - return &e -} -func (e *UpdatePortalUserEmailMessage) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "You will receive a confirmation mail soon on your updated email address.": - *e = UpdatePortalUserEmailMessage(v) - return nil - default: - return fmt.Errorf("invalid value for UpdatePortalUserEmailMessage: %v", v) - } -} - -// UpdatePortalUserEmailResponseBody - Portal user email updated successfully and will receive a confirmation email soon. -type UpdatePortalUserEmailResponseBody struct { - Message *UpdatePortalUserEmailMessage `json:"message,omitempty"` -} - -func (o *UpdatePortalUserEmailResponseBody) GetMessage() *UpdatePortalUserEmailMessage { - if o == nil { - return nil - } - return o.Message -} - -type UpdatePortalUserEmailResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal user email updated successfully and will receive a confirmation email soon. - Object *UpdatePortalUserEmailResponseBody -} - -func (o *UpdatePortalUserEmailResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdatePortalUserEmailResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpdatePortalUserEmailResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdatePortalUserEmailResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdatePortalUserEmailResponse) GetObject() *UpdatePortalUserEmailResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/updateworkflowstepasdone.go b/internal/sdk/models/operations/updateworkflowstepasdone.go deleted file mode 100644 index beef973..0000000 --- a/internal/sdk/models/operations/updateworkflowstepasdone.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "net/http" -) - -type UpdateWorkflowStepAsDoneRequest struct { - StepID string `pathParam:"style=simple,explode=false,name=step_id"` - WorkflowID string `pathParam:"style=simple,explode=false,name=workflow_id"` -} - -func (o *UpdateWorkflowStepAsDoneRequest) GetStepID() string { - if o == nil { - return "" - } - return o.StepID -} - -func (o *UpdateWorkflowStepAsDoneRequest) GetWorkflowID() string { - if o == nil { - return "" - } - return o.WorkflowID -} - -type UpdateWorkflowStepAsDoneResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Updated workflow step successfully - WorkflowStep map[string]any -} - -func (o *UpdateWorkflowStepAsDoneResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpdateWorkflowStepAsDoneResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpdateWorkflowStepAsDoneResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpdateWorkflowStepAsDoneResponse) GetWorkflowStep() map[string]any { - if o == nil { - return nil - } - return o.WorkflowStep -} diff --git a/internal/sdk/models/operations/uploadmeterreadingphoto.go b/internal/sdk/models/operations/uploadmeterreadingphoto.go deleted file mode 100644 index e06c139..0000000 --- a/internal/sdk/models/operations/uploadmeterreadingphoto.go +++ /dev/null @@ -1,68 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -// UploadMeterReadingPhotoResponseBody - Meter reading photo saved successfully. -type UploadMeterReadingPhotoResponseBody struct { - Data *shared.MeterReadingPhotoData `json:"data,omitempty"` -} - -func (o *UploadMeterReadingPhotoResponseBody) GetData() *shared.MeterReadingPhotoData { - if o == nil { - return nil - } - return o.Data -} - -type UploadMeterReadingPhotoResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Meter reading photo saved successfully. - Object *UploadMeterReadingPhotoResponseBody -} - -func (o *UploadMeterReadingPhotoResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UploadMeterReadingPhotoResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UploadMeterReadingPhotoResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UploadMeterReadingPhotoResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UploadMeterReadingPhotoResponse) GetObject() *UploadMeterReadingPhotoResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/upsertemailtemplates.go b/internal/sdk/models/operations/upsertemailtemplates.go deleted file mode 100644 index b4498b6..0000000 --- a/internal/sdk/models/operations/upsertemailtemplates.go +++ /dev/null @@ -1,123 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpsertEmailTemplatesRequest struct { - // Email templates payload - EmailTemplates shared.EmailTemplates `request:"mediaType=application/json"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *UpsertEmailTemplatesRequest) GetEmailTemplates() shared.EmailTemplates { - if o == nil { - return shared.EmailTemplates{} - } - return o.EmailTemplates -} - -func (o *UpsertEmailTemplatesRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type UpsertEmailTemplatesMessage string - -const ( - UpsertEmailTemplatesMessageEmailTemplatesUpsertedSuccessfully UpsertEmailTemplatesMessage = "Email Templates upserted successfully" -) - -func (e UpsertEmailTemplatesMessage) ToPointer() *UpsertEmailTemplatesMessage { - return &e -} -func (e *UpsertEmailTemplatesMessage) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "Email Templates upserted successfully": - *e = UpsertEmailTemplatesMessage(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertEmailTemplatesMessage: %v", v) - } -} - -// UpsertEmailTemplatesResponseBody - Upserted email templates of the portal successfully. -type UpsertEmailTemplatesResponseBody struct { - // Email templates used for authentication and internal processes - EmailTemplates shared.EmailTemplates `json:"emailTemplates"` - Message UpsertEmailTemplatesMessage `json:"message"` -} - -func (o *UpsertEmailTemplatesResponseBody) GetEmailTemplates() shared.EmailTemplates { - if o == nil { - return shared.EmailTemplates{} - } - return o.EmailTemplates -} - -func (o *UpsertEmailTemplatesResponseBody) GetMessage() UpsertEmailTemplatesMessage { - if o == nil { - return UpsertEmailTemplatesMessage("") - } - return o.Message -} - -type UpsertEmailTemplatesResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Upserted email templates of the portal successfully. - Object *UpsertEmailTemplatesResponseBody -} - -func (o *UpsertEmailTemplatesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpsertEmailTemplatesResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpsertEmailTemplatesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpsertEmailTemplatesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpsertEmailTemplatesResponse) GetObject() *UpsertEmailTemplatesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/upsertportal.go b/internal/sdk/models/operations/upsertportal.go deleted file mode 100644 index 621c920..0000000 --- a/internal/sdk/models/operations/upsertportal.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpsertPortalRequest struct { - // Portal payload - UpsertPortalConfig shared.UpsertPortalConfig `request:"mediaType=application/json"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` - // Portal ID - PortalID *string `queryParam:"style=form,explode=true,name=portal_id"` -} - -func (o *UpsertPortalRequest) GetUpsertPortalConfig() shared.UpsertPortalConfig { - if o == nil { - return shared.UpsertPortalConfig{} - } - return o.UpsertPortalConfig -} - -func (o *UpsertPortalRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -func (o *UpsertPortalRequest) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -type UpsertPortalResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // Portal updated successfully. - PortalConfig *shared.PortalConfig - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *UpsertPortalResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpsertPortalResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpsertPortalResponse) GetPortalConfig() *shared.PortalConfig { - if o == nil { - return nil - } - return o.PortalConfig -} - -func (o *UpsertPortalResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpsertPortalResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/operations/upsertportalwidget.go b/internal/sdk/models/operations/upsertportalwidget.go deleted file mode 100644 index afaca22..0000000 --- a/internal/sdk/models/operations/upsertportalwidget.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UpsertPortalWidgetRequest struct { - // Portal widgets payload - UpsertPortalWidget shared.UpsertPortalWidget `request:"mediaType=application/json"` - // Origin of the portal - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *UpsertPortalWidgetRequest) GetUpsertPortalWidget() shared.UpsertPortalWidget { - if o == nil { - return shared.UpsertPortalWidget{} - } - return o.UpsertPortalWidget -} - -func (o *UpsertPortalWidgetRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -type UpsertPortalWidgetResponse struct { - // HTTP response content type for this operation - ContentType string - // The request could not be validated - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Portal widget configuration upserted successfully. - UpsertPortalWidget *shared.UpsertPortalWidget -} - -func (o *UpsertPortalWidgetResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UpsertPortalWidgetResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UpsertPortalWidgetResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UpsertPortalWidgetResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UpsertPortalWidgetResponse) GetUpsertPortalWidget() *shared.UpsertPortalWidget { - if o == nil { - return nil - } - return o.UpsertPortalWidget -} diff --git a/internal/sdk/models/operations/userexists.go b/internal/sdk/models/operations/userexists.go deleted file mode 100644 index ebf0445..0000000 --- a/internal/sdk/models/operations/userexists.go +++ /dev/null @@ -1,97 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type UserExistsRequest struct { - Email string `queryParam:"style=form,explode=true,name=email"` - OrgID string `queryParam:"style=form,explode=true,name=org_id"` - // Checkes if user exists in the given portal origin. If not provided, checks in all origins. - Origin *string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *UserExistsRequest) GetEmail() string { - if o == nil { - return "" - } - return o.Email -} - -func (o *UserExistsRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *UserExistsRequest) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -// UserExistsResponseBody - Returned whether the user exists in the portal or not successfully. -type UserExistsResponseBody struct { - // Whether the user exists in the portal - Exists bool `json:"exists"` -} - -func (o *UserExistsResponseBody) GetExists() bool { - if o == nil { - return false - } - return o.Exists -} - -type UserExistsResponse struct { - // HTTP response content type for this operation - ContentType string - // Internal Server Error - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Returned whether the user exists in the portal or not successfully. - Object *UserExistsResponseBody -} - -func (o *UserExistsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *UserExistsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *UserExistsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *UserExistsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *UserExistsResponse) GetObject() *UserExistsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/validatecaarecords.go b/internal/sdk/models/operations/validatecaarecords.go deleted file mode 100644 index 49fa005..0000000 --- a/internal/sdk/models/operations/validatecaarecords.go +++ /dev/null @@ -1,98 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ValidateCaaRecordsRequest struct { - Origin string `queryParam:"style=form,explode=true,name=origin"` -} - -func (o *ValidateCaaRecordsRequest) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} - -// ValidateCaaRecordsResponseBody - Validated CAA records successfully. -type ValidateCaaRecordsResponseBody struct { - // Whether the DNS is configured from the customer side - IsDNSConfigured *bool `json:"isDNSConfigured,omitempty"` - // Message of the validation - Message *string `json:"message,omitempty"` - // Whether to retry the validation to continue the domain setup - Retry *bool `json:"retry,omitempty"` -} - -func (o *ValidateCaaRecordsResponseBody) GetIsDNSConfigured() *bool { - if o == nil { - return nil - } - return o.IsDNSConfigured -} - -func (o *ValidateCaaRecordsResponseBody) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} - -func (o *ValidateCaaRecordsResponseBody) GetRetry() *bool { - if o == nil { - return nil - } - return o.Retry -} - -type ValidateCaaRecordsResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Validated CAA records successfully. - Object *ValidateCaaRecordsResponseBody -} - -func (o *ValidateCaaRecordsResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ValidateCaaRecordsResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ValidateCaaRecordsResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ValidateCaaRecordsResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ValidateCaaRecordsResponse) GetObject() *ValidateCaaRecordsResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/validatecadenceentityeditrules.go b/internal/sdk/models/operations/validatecadenceentityeditrules.go deleted file mode 100644 index 49e9d7e..0000000 --- a/internal/sdk/models/operations/validatecadenceentityeditrules.go +++ /dev/null @@ -1,97 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ValidateCadenceEntityEditRulesRequest struct { - // Get activities after this timestamp - Attribute *string `queryParam:"style=form,explode=true,name=attribute"` - // Entity id - ID string `pathParam:"style=simple,explode=false,name=id"` - // Entity Type - Slug shared.EntitySlug `pathParam:"style=simple,explode=false,name=slug"` -} - -func (o *ValidateCadenceEntityEditRulesRequest) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *ValidateCadenceEntityEditRulesRequest) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ValidateCadenceEntityEditRulesRequest) GetSlug() shared.EntitySlug { - if o == nil { - return shared.EntitySlug("") - } - return o.Slug -} - -// ValidateCadenceEntityEditRulesResponseBody - Success -type ValidateCadenceEntityEditRulesResponseBody struct { - FailedRule *shared.EntityEditRule `json:"failedRule,omitempty"` - IsBlockedByRules *bool `json:"isBlockedByRules,omitempty"` -} - -func (o *ValidateCadenceEntityEditRulesResponseBody) GetFailedRule() *shared.EntityEditRule { - if o == nil { - return nil - } - return o.FailedRule -} - -func (o *ValidateCadenceEntityEditRulesResponseBody) GetIsBlockedByRules() *bool { - if o == nil { - return nil - } - return o.IsBlockedByRules -} - -type ValidateCadenceEntityEditRulesResponse struct { - // HTTP response content type for this operation - ContentType string - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response - // Success - Object *ValidateCadenceEntityEditRulesResponseBody -} - -func (o *ValidateCadenceEntityEditRulesResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ValidateCadenceEntityEditRulesResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ValidateCadenceEntityEditRulesResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} - -func (o *ValidateCadenceEntityEditRulesResponse) GetObject() *ValidateCadenceEntityEditRulesResponseBody { - if o == nil { - return nil - } - return o.Object -} diff --git a/internal/sdk/models/operations/validatetoken.go b/internal/sdk/models/operations/validatetoken.go deleted file mode 100644 index ba1f71e..0000000 --- a/internal/sdk/models/operations/validatetoken.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "net/http" -) - -type ValidateTokenResponse struct { - // HTTP response content type for this operation - ContentType string - // Could not authenticate the user - ErrorResp *shared.ErrorResp - // HTTP response status code for this operation - StatusCode int - // Raw HTTP response; suitable for custom response parsing - RawResponse *http.Response -} - -func (o *ValidateTokenResponse) GetContentType() string { - if o == nil { - return "" - } - return o.ContentType -} - -func (o *ValidateTokenResponse) GetErrorResp() *shared.ErrorResp { - if o == nil { - return nil - } - return o.ErrorResp -} - -func (o *ValidateTokenResponse) GetStatusCode() int { - if o == nil { - return 0 - } - return o.StatusCode -} - -func (o *ValidateTokenResponse) GetRawResponse() *http.Response { - if o == nil { - return nil - } - return o.RawResponse -} diff --git a/internal/sdk/models/shared/acceptancedecision.go b/internal/sdk/models/shared/acceptancedecision.go deleted file mode 100644 index b9bd561..0000000 --- a/internal/sdk/models/shared/acceptancedecision.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -// Decision - Acceptance decision -type Decision string - -const ( - DecisionAccept Decision = "accept" - DecisionDecline Decision = "decline" -) - -func (e Decision) ToPointer() *Decision { - return &e -} -func (e *Decision) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "accept": - fallthrough - case "decline": - *e = Decision(v) - return nil - default: - return fmt.Errorf("invalid value for Decision: %v", v) - } -} - -type AcceptanceDecision struct { - // Acceptance decision - Decision Decision `json:"decision"` -} - -func (o *AcceptanceDecision) GetDecision() Decision { - if o == nil { - return Decision("") - } - return o.Decision -} diff --git a/internal/sdk/models/shared/actionlabel.go b/internal/sdk/models/shared/actionlabel.go deleted file mode 100644 index 4942397..0000000 --- a/internal/sdk/models/shared/actionlabel.go +++ /dev/null @@ -1,37 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type ActionLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (a ActionLabel) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(a, "", false) -} - -func (a *ActionLabel) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ActionLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *ActionLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} diff --git a/internal/sdk/models/shared/actionwidget.go b/internal/sdk/models/shared/actionwidget.go deleted file mode 100644 index b21ecbf..0000000 --- a/internal/sdk/models/shared/actionwidget.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Headline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (h Headline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(h, "", false) -} - -func (h *Headline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &h, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Headline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *Headline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type SubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (s SubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *SubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type ActionWidgetType string - -const ( - ActionWidgetTypeActionWidget ActionWidgetType = "ACTION_WIDGET" - ActionWidgetTypeContentWidget ActionWidgetType = "CONTENT_WIDGET" - ActionWidgetTypeEntityWidget ActionWidgetType = "ENTITY_WIDGET" - ActionWidgetTypeTeaserWidget ActionWidgetType = "TEASER_WIDGET" - ActionWidgetTypeDocumentWidget ActionWidgetType = "DOCUMENT_WIDGET" - ActionWidgetTypePaymentWidget ActionWidgetType = "PAYMENT_WIDGET" - ActionWidgetTypeMeterReadingWidget ActionWidgetType = "METER_READING_WIDGET" - ActionWidgetTypeMeterChartWidget ActionWidgetType = "METER_CHART_WIDGET" - ActionWidgetTypeCampaignWidget ActionWidgetType = "CAMPAIGN_WIDGET" -) - -func (e ActionWidgetType) ToPointer() *ActionWidgetType { - return &e -} -func (e *ActionWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = ActionWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for ActionWidgetType: %v", v) - } -} - -type ActionWidget struct { - Actions []WidgetAction `json:"actions,omitempty"` - Headline *Headline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - SubHeadline *SubHeadline `json:"subHeadline,omitempty"` - Type ActionWidgetType `json:"type"` -} - -func (a ActionWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(a, "", false) -} - -func (a *ActionWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &a, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *ActionWidget) GetActions() []WidgetAction { - if o == nil { - return nil - } - return o.Actions -} - -func (o *ActionWidget) GetHeadline() *Headline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *ActionWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ActionWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *ActionWidget) GetSubHeadline() *SubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *ActionWidget) GetType() ActionWidgetType { - if o == nil { - return ActionWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/activitycallercontext.go b/internal/sdk/models/shared/activitycallercontext.go deleted file mode 100644 index e734af1..0000000 --- a/internal/sdk/models/shared/activitycallercontext.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Token struct { - CognitoUsername *string `json:"cognito:username,omitempty"` - // Entity ID - CustomContactEntityID *string `json:"custom:contact_entity_id,omitempty"` - // Entity ID - CustomPortalUserID *string `json:"custom:portal_user_id,omitempty"` - Email *string `json:"email,omitempty"` - Sub *string `json:"sub,omitempty"` -} - -func (o *Token) GetCognitoUsername() *string { - if o == nil { - return nil - } - return o.CognitoUsername -} - -func (o *Token) GetCustomContactEntityID() *string { - if o == nil { - return nil - } - return o.CustomContactEntityID -} - -func (o *Token) GetCustomPortalUserID() *string { - if o == nil { - return nil - } - return o.CustomPortalUserID -} - -func (o *Token) GetEmail() *string { - if o == nil { - return nil - } - return o.Email -} - -func (o *Token) GetSub() *string { - if o == nil { - return nil - } - return o.Sub -} - -type PortalAuth struct { - Token *Token `json:"token,omitempty"` -} - -func (o *PortalAuth) GetToken() *Token { - if o == nil { - return nil - } - return o.Token -} - -type ActivityCallerContext struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - PortalAuth *PortalAuth `json:"PortalAuth,omitempty"` -} - -func (a ActivityCallerContext) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(a, "", false) -} - -func (a *ActivityCallerContext) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ActivityCallerContext) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ActivityCallerContext) GetPortalAuth() *PortalAuth { - if o == nil { - return nil - } - return o.PortalAuth -} diff --git a/internal/sdk/models/shared/activityitem.go b/internal/sdk/models/shared/activityitem.go deleted file mode 100644 index 836f7e5..0000000 --- a/internal/sdk/models/shared/activityitem.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type Entity struct { - // Entity ID - ID *string `json:"id,omitempty"` - Schema *string `json:"schema,omitempty"` -} - -func (o *Entity) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *Entity) GetSchema() *string { - if o == nil { - return nil - } - return o.Schema -} - -type Payload struct { - Caller *ActivityCallerContext `json:"caller,omitempty"` - Entity *Entity `json:"entity,omitempty"` -} - -func (o *Payload) GetCaller() *ActivityCallerContext { - if o == nil { - return nil - } - return o.Caller -} - -func (o *Payload) GetEntity() *Entity { - if o == nil { - return nil - } - return o.Entity -} - -type ActivityItem struct { - // See https://github.com/ulid/spec - ID *string `json:"_id,omitempty"` - // Message for activity. Supports handlebars syntax. - Message string `json:"message"` - Payload *Payload `json:"payload,omitempty"` - Timestamp *time.Time `json:"timestamp,omitempty"` - // Title for activity. Supports handlebars syntax. - Title string `json:"title"` - Type string `json:"type"` -} - -func (a ActivityItem) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(a, "", false) -} - -func (a *ActivityItem) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &a, "", false, []string{"message", "title", "type"}); err != nil { - return err - } - return nil -} - -func (o *ActivityItem) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ActivityItem) GetMessage() string { - if o == nil { - return "" - } - return o.Message -} - -func (o *ActivityItem) GetPayload() *Payload { - if o == nil { - return nil - } - return o.Payload -} - -func (o *ActivityItem) GetTimestamp() *time.Time { - if o == nil { - return nil - } - return o.Timestamp -} - -func (o *ActivityItem) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *ActivityItem) GetType() string { - if o == nil { - return "" - } - return o.Type -} diff --git a/internal/sdk/models/shared/adminuser.go b/internal/sdk/models/shared/adminuser.go deleted file mode 100644 index 4996ef3..0000000 --- a/internal/sdk/models/shared/adminuser.go +++ /dev/null @@ -1,120 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type ImageURI struct { - Key *string `json:"key,omitempty"` - Original *string `json:"original,omitempty"` - Thumbnail32 *string `json:"thumbnail_32,omitempty"` - Thumbnail64 *string `json:"thumbnail_64,omitempty"` -} - -func (o *ImageURI) GetKey() *string { - if o == nil { - return nil - } - return o.Key -} - -func (o *ImageURI) GetOriginal() *string { - if o == nil { - return nil - } - return o.Original -} - -func (o *ImageURI) GetThumbnail32() *string { - if o == nil { - return nil - } - return o.Thumbnail32 -} - -func (o *ImageURI) GetThumbnail64() *string { - if o == nil { - return nil - } - return o.Thumbnail64 -} - -type AdminUser struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - DisplayName *string `json:"display_name,omitempty"` - Email *string `json:"email,omitempty"` - ImageURI *ImageURI `json:"image_uri,omitempty"` - OrgID *string `json:"org_id,omitempty"` - Phone *string `json:"phone,omitempty"` - Type *string `json:"type,omitempty"` - UserID *string `json:"user_id,omitempty"` -} - -func (a AdminUser) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(a, "", false) -} - -func (a *AdminUser) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *AdminUser) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *AdminUser) GetDisplayName() *string { - if o == nil { - return nil - } - return o.DisplayName -} - -func (o *AdminUser) GetEmail() *string { - if o == nil { - return nil - } - return o.Email -} - -func (o *AdminUser) GetImageURI() *ImageURI { - if o == nil { - return nil - } - return o.ImageURI -} - -func (o *AdminUser) GetOrgID() *string { - if o == nil { - return nil - } - return o.OrgID -} - -func (o *AdminUser) GetPhone() *string { - if o == nil { - return nil - } - return o.Phone -} - -func (o *AdminUser) GetType() *string { - if o == nil { - return nil - } - return o.Type -} - -func (o *AdminUser) GetUserID() *string { - if o == nil { - return nil - } - return o.UserID -} diff --git a/internal/sdk/models/shared/allowedfileextensions.go b/internal/sdk/models/shared/allowedfileextensions.go deleted file mode 100644 index c12d581..0000000 --- a/internal/sdk/models/shared/allowedfileextensions.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -// AllowedFileExtensions - Allowed file extensions for upload -type AllowedFileExtensions struct { - Archive []string `json:"archive,omitempty"` - AudioVideo []string `json:"audioVideo,omitempty"` - Cad []string `json:"cad,omitempty"` - Calendar []string `json:"calendar,omitempty"` - Document []string `json:"document,omitempty"` - Email []string `json:"email,omitempty"` - Image []string `json:"image,omitempty"` - Other []string `json:"other,omitempty"` - Presentation []string `json:"presentation,omitempty"` - Spreadsheet []string `json:"spreadsheet,omitempty"` -} - -func (o *AllowedFileExtensions) GetArchive() []string { - if o == nil { - return nil - } - return o.Archive -} - -func (o *AllowedFileExtensions) GetAudioVideo() []string { - if o == nil { - return nil - } - return o.AudioVideo -} - -func (o *AllowedFileExtensions) GetCad() []string { - if o == nil { - return nil - } - return o.Cad -} - -func (o *AllowedFileExtensions) GetCalendar() []string { - if o == nil { - return nil - } - return o.Calendar -} - -func (o *AllowedFileExtensions) GetDocument() []string { - if o == nil { - return nil - } - return o.Document -} - -func (o *AllowedFileExtensions) GetEmail() []string { - if o == nil { - return nil - } - return o.Email -} - -func (o *AllowedFileExtensions) GetImage() []string { - if o == nil { - return nil - } - return o.Image -} - -func (o *AllowedFileExtensions) GetOther() []string { - if o == nil { - return nil - } - return o.Other -} - -func (o *AllowedFileExtensions) GetPresentation() []string { - if o == nil { - return nil - } - return o.Presentation -} - -func (o *AllowedFileExtensions) GetSpreadsheet() []string { - if o == nil { - return nil - } - return o.Spreadsheet -} diff --git a/internal/sdk/models/shared/assignment.go b/internal/sdk/models/shared/assignment.go new file mode 100644 index 0000000..d800950 --- /dev/null +++ b/internal/sdk/models/shared/assignment.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +// Assignment - A role attached to an user +type Assignment struct { + Roles []string `json:"roles,omitempty"` + // Id of a user + UserID *string `json:"user_id,omitempty"` +} + +func (a *Assignment) GetRoles() []string { + if a == nil { + return nil + } + return a.Roles +} + +func (a *Assignment) GetUserID() *string { + if a == nil { + return nil + } + return a.UserID +} diff --git a/internal/sdk/models/shared/balance.go b/internal/sdk/models/shared/balance.go deleted file mode 100644 index 758b545..0000000 --- a/internal/sdk/models/shared/balance.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type Balance struct { - // Current balance of the customer in cents. (precision 2) - Balance *int64 `json:"balance,omitempty"` - // Currency code in ISO 4217 format - BalanceCurrency *string `json:"balance_currency,omitempty"` - // Current balance of the customer in decimal string representation. - BalanceDecimal *float64 `json:"balance_decimal,omitempty"` -} - -func (o *Balance) GetBalance() *int64 { - if o == nil { - return nil - } - return o.Balance -} - -func (o *Balance) GetBalanceCurrency() *string { - if o == nil { - return nil - } - return o.BalanceCurrency -} - -func (o *Balance) GetBalanceDecimal() *float64 { - if o == nil { - return nil - } - return o.BalanceDecimal -} diff --git a/internal/sdk/models/shared/billingevent.go b/internal/sdk/models/shared/billingevent.go deleted file mode 100644 index d254e2d..0000000 --- a/internal/sdk/models/shared/billingevent.go +++ /dev/null @@ -1,510 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/types" - "time" -) - -type SchemasDollarRelation struct { - // Entity ID for the related contract. - EntityID *string `json:"entity_id,omitempty"` -} - -func (s SchemasDollarRelation) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasDollarRelation) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasDollarRelation) GetEntityID() *string { - if o == nil { - return nil - } - return o.EntityID -} - -type SchemasContract struct { - DollarRelation []SchemasDollarRelation `json:"$relation,omitempty"` -} - -func (s SchemasContract) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasContract) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasContract) GetDollarRelation() []SchemasDollarRelation { - if o == nil { - return nil - } - return o.DollarRelation -} - -// SchemasReimbursementEventType - Type of the billing event. -type SchemasReimbursementEventType string - -const ( - SchemasReimbursementEventTypeReimbursement SchemasReimbursementEventType = "reimbursement" -) - -func (e SchemasReimbursementEventType) ToPointer() *SchemasReimbursementEventType { - return &e -} -func (e *SchemasReimbursementEventType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "reimbursement": - *e = SchemasReimbursementEventType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasReimbursementEventType: %v", v) - } -} - -// ReimbursementEventSchemas - An entity that describes a reimbursement billing event. -type ReimbursementEventSchemas struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - // Amount to be paid in cents i.e. precision 2 - BillingAmount *int64 `json:"billing_amount,omitempty"` - // Amount to be paid in cents in decimal string representation - BillingAmountDecimal *string `json:"billing_amount_decimal,omitempty"` - // Currency code in ISO 4217 format - BillingCurrency *string `json:"billing_currency,omitempty"` - Contract SchemasContract `json:"contract"` - // Date on which the installment is due. - DueDate *types.Date `json:"due_date,omitempty"` - // Unique identifier for event, used to reference the event to a 3rd party resource such as a SAP Installment. - ExternalID *string `json:"external_id,omitempty"` - // Date on which the customer is reimbursed. - PaidDate *types.Date `json:"paid_date,omitempty"` - // Type of the billing event. - Type SchemasReimbursementEventType `json:"type"` -} - -func (r ReimbursementEventSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(r, "", false) -} - -func (r *ReimbursementEventSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, []string{"_created_at", "_id", "_org", "_title", "_updated_at", "contract", "type"}); err != nil { - return err - } - return nil -} - -func (o *ReimbursementEventSchemas) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ReimbursementEventSchemas) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *ReimbursementEventSchemas) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ReimbursementEventSchemas) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *ReimbursementEventSchemas) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *ReimbursementEventSchemas) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *ReimbursementEventSchemas) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *ReimbursementEventSchemas) GetBillingAmount() *int64 { - if o == nil { - return nil - } - return o.BillingAmount -} - -func (o *ReimbursementEventSchemas) GetBillingAmountDecimal() *string { - if o == nil { - return nil - } - return o.BillingAmountDecimal -} - -func (o *ReimbursementEventSchemas) GetBillingCurrency() *string { - if o == nil { - return nil - } - return o.BillingCurrency -} - -func (o *ReimbursementEventSchemas) GetContract() SchemasContract { - if o == nil { - return SchemasContract{} - } - return o.Contract -} - -func (o *ReimbursementEventSchemas) GetDueDate() *types.Date { - if o == nil { - return nil - } - return o.DueDate -} - -func (o *ReimbursementEventSchemas) GetExternalID() *string { - if o == nil { - return nil - } - return o.ExternalID -} - -func (o *ReimbursementEventSchemas) GetPaidDate() *types.Date { - if o == nil { - return nil - } - return o.PaidDate -} - -func (o *ReimbursementEventSchemas) GetType() SchemasReimbursementEventType { - if o == nil { - return SchemasReimbursementEventType("") - } - return o.Type -} - -type DollarRelation struct { - // Entity ID for the related contract. - EntityID *string `json:"entity_id,omitempty"` -} - -func (d DollarRelation) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(d, "", false) -} - -func (d *DollarRelation) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *DollarRelation) GetEntityID() *string { - if o == nil { - return nil - } - return o.EntityID -} - -type SchemasInstallmentEventContract struct { - DollarRelation []DollarRelation `json:"$relation,omitempty"` -} - -func (s SchemasInstallmentEventContract) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasInstallmentEventContract) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasInstallmentEventContract) GetDollarRelation() []DollarRelation { - if o == nil { - return nil - } - return o.DollarRelation -} - -// SchemasInstallmentEventType - Type of the billing event. -type SchemasInstallmentEventType string - -const ( - SchemasInstallmentEventTypeInstallment SchemasInstallmentEventType = "installment" -) - -func (e SchemasInstallmentEventType) ToPointer() *SchemasInstallmentEventType { - return &e -} -func (e *SchemasInstallmentEventType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "installment": - *e = SchemasInstallmentEventType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasInstallmentEventType: %v", v) - } -} - -// InstallmentEventSchemas - An entity that describes an installment billing event. -type InstallmentEventSchemas struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - // Amount to be paid in cents i.e. precision 2 - BillingAmount *int64 `json:"billing_amount,omitempty"` - // Amount to be paid in cents in decimal string representation - BillingAmountDecimal *string `json:"billing_amount_decimal,omitempty"` - // Currency code in ISO 4217 format - BillingCurrency *string `json:"billing_currency,omitempty"` - Contract SchemasInstallmentEventContract `json:"contract"` - // Date on which the installment is due. - DueDate types.Date `json:"due_date"` - // Unique identifier for event, used to reference the event to a 3rd party resource such as a SAP Installment. - ExternalID *string `json:"external_id,omitempty"` - // Date on which the installment is paid by the customer. - PaidDate *types.Date `json:"paid_date,omitempty"` - // Type of the billing event. - Type SchemasInstallmentEventType `json:"type"` -} - -func (i InstallmentEventSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(i, "", false) -} - -func (i *InstallmentEventSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &i, "", false, []string{"_created_at", "_id", "_org", "_title", "_updated_at", "contract", "due_date", "type"}); err != nil { - return err - } - return nil -} - -func (o *InstallmentEventSchemas) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *InstallmentEventSchemas) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *InstallmentEventSchemas) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *InstallmentEventSchemas) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *InstallmentEventSchemas) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *InstallmentEventSchemas) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *InstallmentEventSchemas) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *InstallmentEventSchemas) GetBillingAmount() *int64 { - if o == nil { - return nil - } - return o.BillingAmount -} - -func (o *InstallmentEventSchemas) GetBillingAmountDecimal() *string { - if o == nil { - return nil - } - return o.BillingAmountDecimal -} - -func (o *InstallmentEventSchemas) GetBillingCurrency() *string { - if o == nil { - return nil - } - return o.BillingCurrency -} - -func (o *InstallmentEventSchemas) GetContract() SchemasInstallmentEventContract { - if o == nil { - return SchemasInstallmentEventContract{} - } - return o.Contract -} - -func (o *InstallmentEventSchemas) GetDueDate() types.Date { - if o == nil { - return types.Date{} - } - return o.DueDate -} - -func (o *InstallmentEventSchemas) GetExternalID() *string { - if o == nil { - return nil - } - return o.ExternalID -} - -func (o *InstallmentEventSchemas) GetPaidDate() *types.Date { - if o == nil { - return nil - } - return o.PaidDate -} - -func (o *InstallmentEventSchemas) GetType() SchemasInstallmentEventType { - if o == nil { - return SchemasInstallmentEventType("") - } - return o.Type -} - -type BillingEventType string - -const ( - BillingEventTypeInstallmentEventSchemas BillingEventType = "InstallmentEvent_Schemas" - BillingEventTypeReimbursementEventSchemas BillingEventType = "ReimbursementEvent_Schemas" -) - -// BillingEvent - An entity that describes a billing event such as a future installment or a reimbursement back to the customer. -type BillingEvent struct { - InstallmentEventSchemas *InstallmentEventSchemas `queryParam:"inline" name:"BillingEvent"` - ReimbursementEventSchemas *ReimbursementEventSchemas `queryParam:"inline" name:"BillingEvent"` - - Type BillingEventType -} - -func CreateBillingEventInstallmentEventSchemas(installmentEventSchemas InstallmentEventSchemas) BillingEvent { - typ := BillingEventTypeInstallmentEventSchemas - - return BillingEvent{ - InstallmentEventSchemas: &installmentEventSchemas, - Type: typ, - } -} - -func CreateBillingEventReimbursementEventSchemas(reimbursementEventSchemas ReimbursementEventSchemas) BillingEvent { - typ := BillingEventTypeReimbursementEventSchemas - - return BillingEvent{ - ReimbursementEventSchemas: &reimbursementEventSchemas, - Type: typ, - } -} - -func (u *BillingEvent) UnmarshalJSON(data []byte) error { - - var installmentEventSchemas InstallmentEventSchemas = InstallmentEventSchemas{} - if err := utils.UnmarshalJSON(data, &installmentEventSchemas, "", true, nil); err == nil { - u.InstallmentEventSchemas = &installmentEventSchemas - u.Type = BillingEventTypeInstallmentEventSchemas - return nil - } - - var reimbursementEventSchemas ReimbursementEventSchemas = ReimbursementEventSchemas{} - if err := utils.UnmarshalJSON(data, &reimbursementEventSchemas, "", true, nil); err == nil { - u.ReimbursementEventSchemas = &reimbursementEventSchemas - u.Type = BillingEventTypeReimbursementEventSchemas - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for BillingEvent", string(data)) -} - -func (u BillingEvent) MarshalJSON() ([]byte, error) { - if u.InstallmentEventSchemas != nil { - return utils.MarshalJSON(u.InstallmentEventSchemas, "", true) - } - - if u.ReimbursementEventSchemas != nil { - return utils.MarshalJSON(u.ReimbursementEventSchemas, "", true) - } - - return nil, errors.New("could not marshal union type BillingEvent: all fields are null") -} diff --git a/internal/sdk/models/shared/block.go b/internal/sdk/models/shared/block.go deleted file mode 100644 index 92a5df7..0000000 --- a/internal/sdk/models/shared/block.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Block struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // The id of the block - ID *string `json:"id,omitempty"` - // The order of the block - Order float64 `json:"order"` - // The id of the parent block - ParentID *string `json:"parentId,omitempty"` - Props *BlockProps `json:"props,omitempty"` - // The type of the block. eg; tabs, tab, group, attribute - Type string `json:"type"` -} - -func (b Block) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(b, "", false) -} - -func (b *Block) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &b, "", false, []string{"order", "type"}); err != nil { - return err - } - return nil -} - -func (o *Block) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Block) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *Block) GetOrder() float64 { - if o == nil { - return 0.0 - } - return o.Order -} - -func (o *Block) GetParentID() *string { - if o == nil { - return nil - } - return o.ParentID -} - -func (o *Block) GetProps() *BlockProps { - if o == nil { - return nil - } - return o.Props -} - -func (o *Block) GetType() string { - if o == nil { - return "" - } - return o.Type -} diff --git a/internal/sdk/models/shared/blockprops.go b/internal/sdk/models/shared/blockprops.go deleted file mode 100644 index 371f18d..0000000 --- a/internal/sdk/models/shared/blockprops.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type BlockProps struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // The content of the block - Content map[string]any `json:"content,omitempty"` - // The design of the block - Design map[string]any `json:"design,omitempty"` - // The conditions that need to be met for the block to be shown - Visibility map[string]any `json:"visibility,omitempty"` -} - -func (b BlockProps) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(b, "", false) -} - -func (b *BlockProps) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &b, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *BlockProps) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *BlockProps) GetContent() map[string]any { - if o == nil { - return nil - } - return o.Content -} - -func (o *BlockProps) GetDesign() map[string]any { - if o == nil { - return nil - } - return o.Design -} - -func (o *BlockProps) GetVisibility() map[string]any { - if o == nil { - return nil - } - return o.Visibility -} diff --git a/internal/sdk/models/shared/blockrequest.go b/internal/sdk/models/shared/blockrequest.go deleted file mode 100644 index 4a31f15..0000000 --- a/internal/sdk/models/shared/blockrequest.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type BlockRequest struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // The order of the block - Order float64 `json:"order"` - // The id of the parent block - ParentID *string `json:"parentId,omitempty"` - Props *BlockProps `json:"props,omitempty"` - // The type of the block. eg; tabs, tab, group, attribute - Type string `json:"type"` -} - -func (b BlockRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(b, "", false) -} - -func (b *BlockRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &b, "", false, []string{"order", "type"}); err != nil { - return err - } - return nil -} - -func (o *BlockRequest) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *BlockRequest) GetOrder() float64 { - if o == nil { - return 0.0 - } - return o.Order -} - -func (o *BlockRequest) GetParentID() *string { - if o == nil { - return nil - } - return o.ParentID -} - -func (o *BlockRequest) GetProps() *BlockProps { - if o == nil { - return nil - } - return o.Props -} - -func (o *BlockRequest) GetType() string { - if o == nil { - return "" - } - return o.Type -} diff --git a/internal/sdk/models/shared/campaignwidget.go b/internal/sdk/models/shared/campaignwidget.go deleted file mode 100644 index 096e672..0000000 --- a/internal/sdk/models/shared/campaignwidget.go +++ /dev/null @@ -1,256 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type CampaignWidgetLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (c CampaignWidgetLabel) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *CampaignWidgetLabel) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *CampaignWidgetLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *CampaignWidgetLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type Button struct { - Label *CampaignWidgetLabel `json:"label,omitempty"` - URL *string `json:"url,omitempty"` -} - -func (b Button) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(b, "", false) -} - -func (b *Button) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &b, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Button) GetLabel() *CampaignWidgetLabel { - if o == nil { - return nil - } - return o.Label -} - -func (o *Button) GetURL() *string { - if o == nil { - return nil - } - return o.URL -} - -type CampaignWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (c CampaignWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *CampaignWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *CampaignWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *CampaignWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type CampaignWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (c CampaignWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *CampaignWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *CampaignWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *CampaignWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type CampaignWidgetType string - -const ( - CampaignWidgetTypeActionWidget CampaignWidgetType = "ACTION_WIDGET" - CampaignWidgetTypeContentWidget CampaignWidgetType = "CONTENT_WIDGET" - CampaignWidgetTypeEntityWidget CampaignWidgetType = "ENTITY_WIDGET" - CampaignWidgetTypeTeaserWidget CampaignWidgetType = "TEASER_WIDGET" - CampaignWidgetTypeDocumentWidget CampaignWidgetType = "DOCUMENT_WIDGET" - CampaignWidgetTypePaymentWidget CampaignWidgetType = "PAYMENT_WIDGET" - CampaignWidgetTypeMeterReadingWidget CampaignWidgetType = "METER_READING_WIDGET" - CampaignWidgetTypeMeterChartWidget CampaignWidgetType = "METER_CHART_WIDGET" - CampaignWidgetTypeCampaignWidget CampaignWidgetType = "CAMPAIGN_WIDGET" -) - -func (e CampaignWidgetType) ToPointer() *CampaignWidgetType { - return &e -} -func (e *CampaignWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = CampaignWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for CampaignWidgetType: %v", v) - } -} - -type CampaignWidget struct { - Button *Button `json:"button,omitempty"` - // ID of the campaign - CampaignID *string `json:"campaign_id,omitempty"` - Headline *CampaignWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - ImageURL *string `json:"imageUrl,omitempty"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - SubHeadline *CampaignWidgetSubHeadline `json:"subHeadline,omitempty"` - Type CampaignWidgetType `json:"type"` -} - -func (c CampaignWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *CampaignWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *CampaignWidget) GetButton() *Button { - if o == nil { - return nil - } - return o.Button -} - -func (o *CampaignWidget) GetCampaignID() *string { - if o == nil { - return nil - } - return o.CampaignID -} - -func (o *CampaignWidget) GetHeadline() *CampaignWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *CampaignWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *CampaignWidget) GetImageURL() *string { - if o == nil { - return nil - } - return o.ImageURL -} - -func (o *CampaignWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *CampaignWidget) GetSubHeadline() *CampaignWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *CampaignWidget) GetType() CampaignWidgetType { - if o == nil { - return CampaignWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/contact.go b/internal/sdk/models/shared/contact.go deleted file mode 100644 index 77a5505..0000000 --- a/internal/sdk/models/shared/contact.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type ContactSchema string - -const ( - ContactSchemaContact ContactSchema = "contact" -) - -func (e ContactSchema) ToPointer() *ContactSchema { - return &e -} -func (e *ContactSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contact": - *e = ContactSchema(v) - return nil - default: - return fmt.Errorf("invalid value for ContactSchema: %v", v) - } -} - -// Contact - The mapped contact of the portal user -type Contact struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema ContactSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (c Contact) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *Contact) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Contact) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Contact) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Contact) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Contact) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Contact) GetSchema() ContactSchema { - if o == nil { - return ContactSchema("") - } - return o.Schema -} - -func (o *Contact) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Contact) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Contact) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/contactexistsrequest.go b/internal/sdk/models/shared/contactexistsrequest.go deleted file mode 100644 index 5b74603..0000000 --- a/internal/sdk/models/shared/contactexistsrequest.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ContactExistsRequest struct { - // ID of the organization - OrgID string `json:"org_id"` - // Identifier-value pairs per schema to identify a contact of a portal user during the resgistration - RegistrationIdentifiers map[string]map[string]string `json:"registration_identifiers"` -} - -func (o *ContactExistsRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *ContactExistsRequest) GetRegistrationIdentifiers() map[string]map[string]string { - if o == nil { - return map[string]map[string]string{} - } - return o.RegistrationIdentifiers -} diff --git a/internal/sdk/models/shared/contentwidget.go b/internal/sdk/models/shared/contentwidget.go deleted file mode 100644 index 694707a..0000000 --- a/internal/sdk/models/shared/contentwidget.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type ContentWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (c ContentWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *ContentWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ContentWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *ContentWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type ContentWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (c ContentWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *ContentWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ContentWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *ContentWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type ContentWidgetType string - -const ( - ContentWidgetTypeActionWidget ContentWidgetType = "ACTION_WIDGET" - ContentWidgetTypeContentWidget ContentWidgetType = "CONTENT_WIDGET" - ContentWidgetTypeEntityWidget ContentWidgetType = "ENTITY_WIDGET" - ContentWidgetTypeTeaserWidget ContentWidgetType = "TEASER_WIDGET" - ContentWidgetTypeDocumentWidget ContentWidgetType = "DOCUMENT_WIDGET" - ContentWidgetTypePaymentWidget ContentWidgetType = "PAYMENT_WIDGET" - ContentWidgetTypeMeterReadingWidget ContentWidgetType = "METER_READING_WIDGET" - ContentWidgetTypeMeterChartWidget ContentWidgetType = "METER_CHART_WIDGET" - ContentWidgetTypeCampaignWidget ContentWidgetType = "CAMPAIGN_WIDGET" -) - -func (e ContentWidgetType) ToPointer() *ContentWidgetType { - return &e -} -func (e *ContentWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = ContentWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for ContentWidgetType: %v", v) - } -} - -type ContentWidget struct { - Content *string `json:"content,omitempty"` - Headline *ContentWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - SubHeadline *ContentWidgetSubHeadline `json:"subHeadline,omitempty"` - Type ContentWidgetType `json:"type"` -} - -func (c ContentWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *ContentWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *ContentWidget) GetContent() *string { - if o == nil { - return nil - } - return o.Content -} - -func (o *ContentWidget) GetHeadline() *ContentWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *ContentWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ContentWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *ContentWidget) GetSubHeadline() *ContentWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *ContentWidget) GetType() ContentWidgetType { - if o == nil { - return ContentWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/contract.go b/internal/sdk/models/shared/contract.go deleted file mode 100644 index f4ccbaf..0000000 --- a/internal/sdk/models/shared/contract.go +++ /dev/null @@ -1,462 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -// BillingPeriod - The billing period associated with the contract. -type BillingPeriod string - -const ( - BillingPeriodWeekly BillingPeriod = "weekly" - BillingPeriodMonthly BillingPeriod = "monthly" - BillingPeriodEveryQuarter BillingPeriod = "every_quarter" - BillingPeriodEvery6Months BillingPeriod = "every_6_months" - BillingPeriodYearly BillingPeriod = "yearly" -) - -func (e BillingPeriod) ToPointer() *BillingPeriod { - return &e -} -func (e *BillingPeriod) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weekly": - fallthrough - case "monthly": - fallthrough - case "every_quarter": - fallthrough - case "every_6_months": - fallthrough - case "yearly": - *e = BillingPeriod(v) - return nil - default: - return fmt.Errorf("invalid value for BillingPeriod: %v", v) - } -} - -// Branch - The branch associated with the contract. -type Branch string - -const ( - BranchPower Branch = "power" - BranchGas Branch = "gas" - BranchWater Branch = "water" - BranchWasteWater Branch = "waste_water" - BranchDistrictHeating Branch = "district_heating" -) - -func (e Branch) ToPointer() *Branch { - return &e -} -func (e *Branch) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "power": - fallthrough - case "gas": - fallthrough - case "water": - fallthrough - case "waste_water": - fallthrough - case "district_heating": - *e = Branch(v) - return nil - default: - return fmt.Errorf("invalid value for Branch: %v", v) - } -} - -// NoticeTimeUnit - The unit of time for the notice period. -type NoticeTimeUnit string - -const ( - NoticeTimeUnitWeeks NoticeTimeUnit = "weeks" - NoticeTimeUnitMonths NoticeTimeUnit = "months" - NoticeTimeUnitYears NoticeTimeUnit = "years" -) - -func (e NoticeTimeUnit) ToPointer() *NoticeTimeUnit { - return &e -} -func (e *NoticeTimeUnit) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weeks": - fallthrough - case "months": - fallthrough - case "years": - *e = NoticeTimeUnit(v) - return nil - default: - return fmt.Errorf("invalid value for NoticeTimeUnit: %v", v) - } -} - -// RenewalDurationUnit - The unit of time for the renewal period. -type RenewalDurationUnit string - -const ( - RenewalDurationUnitWeeks RenewalDurationUnit = "weeks" - RenewalDurationUnitMonths RenewalDurationUnit = "months" - RenewalDurationUnitYears RenewalDurationUnit = "years" -) - -func (e RenewalDurationUnit) ToPointer() *RenewalDurationUnit { - return &e -} -func (e *RenewalDurationUnit) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "weeks": - fallthrough - case "months": - fallthrough - case "years": - *e = RenewalDurationUnit(v) - return nil - default: - return fmt.Errorf("invalid value for RenewalDurationUnit: %v", v) - } -} - -// Status - The status of the contract. -type Status string - -const ( - StatusDraft Status = "draft" - StatusInApprovalProcess Status = "in_approval_process" - StatusApproved Status = "approved" - StatusActive Status = "active" - StatusDeactivated Status = "deactivated" - StatusRevoked Status = "revoked" - StatusTerminated Status = "terminated" - StatusExpired Status = "expired" -) - -func (e Status) ToPointer() *Status { - return &e -} -func (e *Status) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "draft": - fallthrough - case "in_approval_process": - fallthrough - case "approved": - fallthrough - case "active": - fallthrough - case "deactivated": - fallthrough - case "revoked": - fallthrough - case "terminated": - fallthrough - case "expired": - *e = Status(v) - return nil - default: - return fmt.Errorf("invalid value for Status: %v", v) - } -} - -// Contract - The contract entity -type Contract struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - // The account number associated with the contract. - AccountNumber *string `json:"account_number,omitempty"` - // Any additional addresses associated with the contract. - AdditionalAddresses *string `json:"additional_addresses,omitempty"` - // Current balance of the contract in cents. (precision 2) - Balance *int64 `json:"balance,omitempty"` - // Currency code in ISO 4217 format - BalanceCurrency *string `json:"balance_currency,omitempty"` - // The billing address associated with the contract. - BillingAddress *string `json:"billing_address,omitempty"` - // Defines the day of the month in which the installments are due. - BillingDueDay *int64 `json:"billing_due_day,omitempty"` - // The duration of the billing period. - BillingDurationAmount *float64 `json:"billing_duration_amount,omitempty"` - // The billing period associated with the contract. - BillingPeriod *BillingPeriod `default:"weekly" json:"billing_period"` - // The branch associated with the contract. - Branch *Branch `json:"branch,omitempty"` - // The name of the contract. - ContractName *string `json:"contract_name,omitempty"` - // The unique identifier of the contract. - ContractNumber *string `json:"contract_number,omitempty"` - // The delivery address associated with the contract. - DeliveryAddress *string `json:"delivery_address,omitempty"` - // A brief description of the contract. - Description *string `json:"description,omitempty"` - // Set amount for installments in cents. (precision 2) - InstallmentAmount *int64 `json:"installment_amount,omitempty"` - // The amount of notice required for termination of the contract. - NoticeTimeAmount *float64 `json:"notice_time_amount,omitempty"` - // The unit of time for the notice period. - NoticeTimeUnit *NoticeTimeUnit `default:"months" json:"notice_time_unit"` - // The duration of the renewal period. - RenewalDurationAmount *float64 `json:"renewal_duration_amount,omitempty"` - // The unit of time for the renewal period. - RenewalDurationUnit *RenewalDurationUnit `default:"months" json:"renewal_duration_unit"` - // The start date of the contract. - StartDate *string `json:"start_date,omitempty"` - // The status of the contract. - Status *Status `default:"draft" json:"status"` - // The date on which the contract was terminated. - TerminationDate *string `json:"termination_date,omitempty"` - // The reason for the termination of the contract. - TerminationReason *string `json:"termination_reason,omitempty"` -} - -func (c Contract) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *Contract) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"_created_at", "_id", "_org", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Contract) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Contract) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Contract) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Contract) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Contract) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Contract) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Contract) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *Contract) GetAccountNumber() *string { - if o == nil { - return nil - } - return o.AccountNumber -} - -func (o *Contract) GetAdditionalAddresses() *string { - if o == nil { - return nil - } - return o.AdditionalAddresses -} - -func (o *Contract) GetBalance() *int64 { - if o == nil { - return nil - } - return o.Balance -} - -func (o *Contract) GetBalanceCurrency() *string { - if o == nil { - return nil - } - return o.BalanceCurrency -} - -func (o *Contract) GetBillingAddress() *string { - if o == nil { - return nil - } - return o.BillingAddress -} - -func (o *Contract) GetBillingDueDay() *int64 { - if o == nil { - return nil - } - return o.BillingDueDay -} - -func (o *Contract) GetBillingDurationAmount() *float64 { - if o == nil { - return nil - } - return o.BillingDurationAmount -} - -func (o *Contract) GetBillingPeriod() *BillingPeriod { - if o == nil { - return nil - } - return o.BillingPeriod -} - -func (o *Contract) GetBranch() *Branch { - if o == nil { - return nil - } - return o.Branch -} - -func (o *Contract) GetContractName() *string { - if o == nil { - return nil - } - return o.ContractName -} - -func (o *Contract) GetContractNumber() *string { - if o == nil { - return nil - } - return o.ContractNumber -} - -func (o *Contract) GetDeliveryAddress() *string { - if o == nil { - return nil - } - return o.DeliveryAddress -} - -func (o *Contract) GetDescription() *string { - if o == nil { - return nil - } - return o.Description -} - -func (o *Contract) GetInstallmentAmount() *int64 { - if o == nil { - return nil - } - return o.InstallmentAmount -} - -func (o *Contract) GetNoticeTimeAmount() *float64 { - if o == nil { - return nil - } - return o.NoticeTimeAmount -} - -func (o *Contract) GetNoticeTimeUnit() *NoticeTimeUnit { - if o == nil { - return nil - } - return o.NoticeTimeUnit -} - -func (o *Contract) GetRenewalDurationAmount() *float64 { - if o == nil { - return nil - } - return o.RenewalDurationAmount -} - -func (o *Contract) GetRenewalDurationUnit() *RenewalDurationUnit { - if o == nil { - return nil - } - return o.RenewalDurationUnit -} - -func (o *Contract) GetStartDate() *string { - if o == nil { - return nil - } - return o.StartDate -} - -func (o *Contract) GetStatus() *Status { - if o == nil { - return nil - } - return o.Status -} - -func (o *Contract) GetTerminationDate() *string { - if o == nil { - return nil - } - return o.TerminationDate -} - -func (o *Contract) GetTerminationReason() *string { - if o == nil { - return nil - } - return o.TerminationReason -} diff --git a/internal/sdk/models/shared/contractidentifier.go b/internal/sdk/models/shared/contractidentifier.go deleted file mode 100644 index 58963f6..0000000 --- a/internal/sdk/models/shared/contractidentifier.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ContractIdentifier struct { - // Name of the identifier/attribute - Name *string `json:"name,omitempty"` - // URL-friendly identifier for the entity schema - Schema *EntitySlug `json:"schema,omitempty"` -} - -func (o *ContractIdentifier) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *ContractIdentifier) GetSchema() *EntitySlug { - if o == nil { - return nil - } - return o.Schema -} diff --git a/internal/sdk/models/shared/createrolepayload.go b/internal/sdk/models/shared/createrolepayload.go new file mode 100644 index 0000000..afb9663 --- /dev/null +++ b/internal/sdk/models/shared/createrolepayload.go @@ -0,0 +1,584 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +// Five - A role that is applied to end customers and installers using the Portals +type Five struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID *string `json:"id,omitempty"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID *string `json:"organization_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + // Type of the role + Type string `json:"type"` +} + +func (f Five) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(f, "", false) +} + +func (f *Five) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &f, "", false, []string{"grants", "name", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (f *Five) GetExpiresAt() *time.Time { + if f == nil { + return nil + } + return f.ExpiresAt +} + +func (f *Five) GetGrants() []Grant { + if f == nil { + return []Grant{} + } + return f.Grants +} + +func (f *Five) GetID() *string { + if f == nil { + return nil + } + return f.ID +} + +func (f *Five) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *Five) GetOrganizationID() *string { + if f == nil { + return nil + } + return f.OrganizationID +} + +func (f *Five) GetSlug() string { + if f == nil { + return "" + } + return f.Slug +} + +func (f *Five) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +// Four - A role that appears in another organization's role list that can be assigned but not modified by the partner organization. +type Four struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID *string `json:"id,omitempty"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID *string `json:"organization_id,omitempty"` + PartnerOrgID *string `json:"partner_org_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + // Type of the role + Type string `json:"type"` +} + +func (f Four) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(f, "", false) +} + +func (f *Four) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &f, "", false, []string{"grants", "name", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (f *Four) GetExpiresAt() *time.Time { + if f == nil { + return nil + } + return f.ExpiresAt +} + +func (f *Four) GetGrants() []Grant { + if f == nil { + return []Grant{} + } + return f.Grants +} + +func (f *Four) GetID() *string { + if f == nil { + return nil + } + return f.ID +} + +func (f *Four) GetName() string { + if f == nil { + return "" + } + return f.Name +} + +func (f *Four) GetOrganizationID() *string { + if f == nil { + return nil + } + return f.OrganizationID +} + +func (f *Four) GetPartnerOrgID() *string { + if f == nil { + return nil + } + return f.PartnerOrgID +} + +func (f *Four) GetSlug() string { + if f == nil { + return "" + } + return f.Slug +} + +func (f *Four) GetType() string { + if f == nil { + return "" + } + return f.Type +} + +// Three - A role that can be assigned to users in other organizations for sharing purposes. +type Three struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID *string `json:"id,omitempty"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID *string `json:"organization_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + // Type of the role + Type string `json:"type"` +} + +func (t Three) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *Three) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, []string{"grants", "name", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (t *Three) GetExpiresAt() *time.Time { + if t == nil { + return nil + } + return t.ExpiresAt +} + +func (t *Three) GetGrants() []Grant { + if t == nil { + return []Grant{} + } + return t.Grants +} + +func (t *Three) GetID() *string { + if t == nil { + return nil + } + return t.ID +} + +func (t *Three) GetName() string { + if t == nil { + return "" + } + return t.Name +} + +func (t *Three) GetOrganizationID() *string { + if t == nil { + return nil + } + return t.OrganizationID +} + +func (t *Three) GetSlug() string { + if t == nil { + return "" + } + return t.Slug +} + +func (t *Three) GetType() string { + if t == nil { + return "" + } + return t.Type +} + +// Two - A role automatically applied to all users in an organization. +type Two struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID *string `json:"id,omitempty"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID *string `json:"organization_id,omitempty"` + // The pricing tier of the organization this root role is based on + PricingTier *string `json:"pricing_tier,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + // Type of the role + Type string `json:"type"` +} + +func (t Two) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(t, "", false) +} + +func (t *Two) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &t, "", false, []string{"grants", "name", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (t *Two) GetExpiresAt() *time.Time { + if t == nil { + return nil + } + return t.ExpiresAt +} + +func (t *Two) GetGrants() []Grant { + if t == nil { + return []Grant{} + } + return t.Grants +} + +func (t *Two) GetID() *string { + if t == nil { + return nil + } + return t.ID +} + +func (t *Two) GetName() string { + if t == nil { + return "" + } + return t.Name +} + +func (t *Two) GetOrganizationID() *string { + if t == nil { + return nil + } + return t.OrganizationID +} + +func (t *Two) GetPricingTier() *string { + if t == nil { + return nil + } + return t.PricingTier +} + +func (t *Two) GetSlug() string { + if t == nil { + return "" + } + return t.Slug +} + +func (t *Two) GetType() string { + if t == nil { + return "" + } + return t.Type +} + +// One - A standard user role. Must be explicitly assigned to users. +type One struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID *string `json:"id,omitempty"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID *string `json:"organization_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + // Type of the role + Type string `json:"type"` +} + +func (o One) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *One) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"grants", "name", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (o *One) GetExpiresAt() *time.Time { + if o == nil { + return nil + } + return o.ExpiresAt +} + +func (o *One) GetGrants() []Grant { + if o == nil { + return []Grant{} + } + return o.Grants +} + +func (o *One) GetID() *string { + if o == nil { + return nil + } + return o.ID +} + +func (o *One) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *One) GetOrganizationID() *string { + if o == nil { + return nil + } + return o.OrganizationID +} + +func (o *One) GetSlug() string { + if o == nil { + return "" + } + return o.Slug +} + +func (o *One) GetType() string { + if o == nil { + return "" + } + return o.Type +} + +type CreateRolePayloadType string + +const ( + CreateRolePayloadTypeOne CreateRolePayloadType = "1" + CreateRolePayloadTypeTwo CreateRolePayloadType = "2" + CreateRolePayloadTypeThree CreateRolePayloadType = "3" + CreateRolePayloadTypeFour CreateRolePayloadType = "4" + CreateRolePayloadTypeFive CreateRolePayloadType = "5" +) + +type CreateRolePayload struct { + One *One `queryParam:"inline,name=CreateRolePayload"` + Two *Two `queryParam:"inline,name=CreateRolePayload"` + Three *Three `queryParam:"inline,name=CreateRolePayload"` + Four *Four `queryParam:"inline,name=CreateRolePayload"` + Five *Five `queryParam:"inline,name=CreateRolePayload"` + + Type CreateRolePayloadType +} + +func CreateCreateRolePayloadOne(one One) CreateRolePayload { + typ := CreateRolePayloadTypeOne + + return CreateRolePayload{ + One: &one, + Type: typ, + } +} + +func CreateCreateRolePayloadTwo(two Two) CreateRolePayload { + typ := CreateRolePayloadTypeTwo + + return CreateRolePayload{ + Two: &two, + Type: typ, + } +} + +func CreateCreateRolePayloadThree(three Three) CreateRolePayload { + typ := CreateRolePayloadTypeThree + + return CreateRolePayload{ + Three: &three, + Type: typ, + } +} + +func CreateCreateRolePayloadFour(four Four) CreateRolePayload { + typ := CreateRolePayloadTypeFour + + return CreateRolePayload{ + Four: &four, + Type: typ, + } +} + +func CreateCreateRolePayloadFive(five Five) CreateRolePayload { + typ := CreateRolePayloadTypeFive + + return CreateRolePayload{ + Five: &five, + Type: typ, + } +} + +func (u *CreateRolePayload) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var one One = One{} + if err := utils.UnmarshalJSON(data, &one, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateRolePayloadTypeOne, + Value: &one, + }) + } + + var two Two = Two{} + if err := utils.UnmarshalJSON(data, &two, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateRolePayloadTypeTwo, + Value: &two, + }) + } + + var three Three = Three{} + if err := utils.UnmarshalJSON(data, &three, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateRolePayloadTypeThree, + Value: &three, + }) + } + + var four Four = Four{} + if err := utils.UnmarshalJSON(data, &four, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateRolePayloadTypeFour, + Value: &four, + }) + } + + var five Five = Five{} + if err := utils.UnmarshalJSON(data, &five, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: CreateRolePayloadTypeFive, + Value: &five, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateRolePayload", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateRolePayload", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(CreateRolePayloadType) + switch best.Type { + case CreateRolePayloadTypeOne: + u.One = best.Value.(*One) + return nil + case CreateRolePayloadTypeTwo: + u.Two = best.Value.(*Two) + return nil + case CreateRolePayloadTypeThree: + u.Three = best.Value.(*Three) + return nil + case CreateRolePayloadTypeFour: + u.Four = best.Value.(*Four) + return nil + case CreateRolePayloadTypeFive: + u.Five = best.Value.(*Five) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateRolePayload", string(data)) +} + +func (u CreateRolePayload) MarshalJSON() ([]byte, error) { + if u.One != nil { + return utils.MarshalJSON(u.One, "", true) + } + + if u.Two != nil { + return utils.MarshalJSON(u.Two, "", true) + } + + if u.Three != nil { + return utils.MarshalJSON(u.Three, "", true) + } + + if u.Four != nil { + return utils.MarshalJSON(u.Four, "", true) + } + + if u.Five != nil { + return utils.MarshalJSON(u.Five, "", true) + } + + return nil, errors.New("could not marshal union type CreateRolePayload: all fields are null") +} diff --git a/internal/sdk/models/shared/createuserrequest.go b/internal/sdk/models/shared/createuserrequest.go deleted file mode 100644 index bdb106c..0000000 --- a/internal/sdk/models/shared/createuserrequest.go +++ /dev/null @@ -1,80 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type CreateUserRequest struct { - // Entity ID - ContactID *string `json:"contactId,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers map[string]string `json:"contactIdentifiers,omitempty"` - // User's email address - Email string `json:"email"` - // First Name of the portal user - FirstName *string `json:"first_name,omitempty"` - // Last Name of the portal user - LastName *string `json:"last_name,omitempty"` - // ID of the organization - OrgID string `json:"orgId"` - // User's password - Password string `json:"password"` - // Identifier-value pairs per schema to identify a contact of a portal user during the resgistration - RegistrationIdentifiers map[string]map[string]string `json:"registration_identifiers,omitempty"` -} - -func (o *CreateUserRequest) GetContactID() *string { - if o == nil { - return nil - } - return o.ContactID -} - -func (o *CreateUserRequest) GetContactIdentifiers() map[string]string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *CreateUserRequest) GetEmail() string { - if o == nil { - return "" - } - return o.Email -} - -func (o *CreateUserRequest) GetFirstName() *string { - if o == nil { - return nil - } - return o.FirstName -} - -func (o *CreateUserRequest) GetLastName() *string { - if o == nil { - return nil - } - return o.LastName -} - -func (o *CreateUserRequest) GetOrgID() string { - if o == nil { - return "" - } - return o.OrgID -} - -func (o *CreateUserRequest) GetPassword() string { - if o == nil { - return "" - } - return o.Password -} - -func (o *CreateUserRequest) GetRegistrationIdentifiers() map[string]map[string]string { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} diff --git a/internal/sdk/models/shared/dataretrievalitem.go b/internal/sdk/models/shared/dataretrievalitem.go deleted file mode 100644 index 9935d68..0000000 --- a/internal/sdk/models/shared/dataretrievalitem.go +++ /dev/null @@ -1,22 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type DataRetrievalItem struct { - Extension *PublicExtensionDetails `json:"extension,omitempty"` - Hook *PublicDataRetrievalHookDetails `json:"hook,omitempty"` -} - -func (o *DataRetrievalItem) GetExtension() *PublicExtensionDetails { - if o == nil { - return nil - } - return o.Extension -} - -func (o *DataRetrievalItem) GetHook() *PublicDataRetrievalHookDetails { - if o == nil { - return nil - } - return o.Hook -} diff --git a/internal/sdk/models/shared/deleteentityfile.go b/internal/sdk/models/shared/deleteentityfile.go deleted file mode 100644 index e546d62..0000000 --- a/internal/sdk/models/shared/deleteentityfile.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type DeleteEntityFile struct { - // Entity ID - EntityID string `json:"entity_id"` - // Entity type - EntityType string `json:"entity_type"` - // Array of file entity IDs - FileEntityIds []string `json:"file_entity_ids"` -} - -func (o *DeleteEntityFile) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *DeleteEntityFile) GetEntityType() string { - if o == nil { - return "" - } - return o.EntityType -} - -func (o *DeleteEntityFile) GetFileEntityIds() []string { - if o == nil { - return []string{} - } - return o.FileEntityIds -} diff --git a/internal/sdk/models/shared/emailtemplates.go b/internal/sdk/models/shared/emailtemplates.go deleted file mode 100644 index d4cdf87..0000000 --- a/internal/sdk/models/shared/emailtemplates.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -// EmailTemplates - Email templates used for authentication and internal processes -type EmailTemplates struct { - // Entity ID - AdvancedAuth *string `json:"advancedAuth,omitempty"` - // Entity ID - AdvancedMFA *string `json:"advancedMFA,omitempty"` - // Entity ID - ConfirmAccount *string `json:"confirmAccount,omitempty"` - // Entity ID - ConfirmEmailUpdate *string `json:"confirmEmailUpdate,omitempty"` - // Entity ID - ForgotPassword *string `json:"forgotPassword,omitempty"` - // Entity ID - Invitation *string `json:"invitation,omitempty"` - // Entity ID - JourneyLoginOTP *string `json:"journeyLoginOTP,omitempty"` - // Entity ID - JourneySignInOneTimePassword *string `json:"journeySignInOneTimePassword,omitempty"` - // Entity ID - JourneySignUp *string `json:"journeySignUp,omitempty"` - // Entity ID - OnDocUpload *string `json:"onDocUpload,omitempty"` - // Entity ID - OnMapAPendingUser *string `json:"onMapAPendingUser,omitempty"` - // Entity ID - OnNewQuote *string `json:"onNewQuote,omitempty"` - // Entity ID - OnWorkflowStepAssigned *string `json:"onWorkflowStepAssigned,omitempty"` - // Entity ID - VerifyCodeToSetPassword *string `json:"verifyCodeToSetPassword,omitempty"` -} - -func (o *EmailTemplates) GetAdvancedAuth() *string { - if o == nil { - return nil - } - return o.AdvancedAuth -} - -func (o *EmailTemplates) GetAdvancedMFA() *string { - if o == nil { - return nil - } - return o.AdvancedMFA -} - -func (o *EmailTemplates) GetConfirmAccount() *string { - if o == nil { - return nil - } - return o.ConfirmAccount -} - -func (o *EmailTemplates) GetConfirmEmailUpdate() *string { - if o == nil { - return nil - } - return o.ConfirmEmailUpdate -} - -func (o *EmailTemplates) GetForgotPassword() *string { - if o == nil { - return nil - } - return o.ForgotPassword -} - -func (o *EmailTemplates) GetInvitation() *string { - if o == nil { - return nil - } - return o.Invitation -} - -func (o *EmailTemplates) GetJourneyLoginOTP() *string { - if o == nil { - return nil - } - return o.JourneyLoginOTP -} - -func (o *EmailTemplates) GetJourneySignInOneTimePassword() *string { - if o == nil { - return nil - } - return o.JourneySignInOneTimePassword -} - -func (o *EmailTemplates) GetJourneySignUp() *string { - if o == nil { - return nil - } - return o.JourneySignUp -} - -func (o *EmailTemplates) GetOnDocUpload() *string { - if o == nil { - return nil - } - return o.OnDocUpload -} - -func (o *EmailTemplates) GetOnMapAPendingUser() *string { - if o == nil { - return nil - } - return o.OnMapAPendingUser -} - -func (o *EmailTemplates) GetOnNewQuote() *string { - if o == nil { - return nil - } - return o.OnNewQuote -} - -func (o *EmailTemplates) GetOnWorkflowStepAssigned() *string { - if o == nil { - return nil - } - return o.OnWorkflowStepAssigned -} - -func (o *EmailTemplates) GetVerifyCodeToSetPassword() *string { - if o == nil { - return nil - } - return o.VerifyCodeToSetPassword -} diff --git a/internal/sdk/models/shared/entityeditrule.go b/internal/sdk/models/shared/entityeditrule.go deleted file mode 100644 index dbc9222..0000000 --- a/internal/sdk/models/shared/entityeditrule.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type EntityEditRule struct { - AllowedDecrement *string `json:"allowed_decrement,omitempty"` - AllowedIncrement *string `json:"allowed_increment,omitempty"` - Attribute *string `json:"attribute,omitempty"` - CadencePeriod *float64 `json:"cadence_period,omitempty"` - CadencePeriodType *string `json:"cadence_period_type,omitempty"` - ChangesAllowed *float64 `json:"changes_allowed,omitempty"` - GracePeriod *float64 `json:"grace_period,omitempty"` - NumberOfDaysBeforeRestriction *float64 `json:"number_of_days_before_restriction,omitempty"` - RuleType *string `json:"rule_type,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *EntityEditRule) GetAllowedDecrement() *string { - if o == nil { - return nil - } - return o.AllowedDecrement -} - -func (o *EntityEditRule) GetAllowedIncrement() *string { - if o == nil { - return nil - } - return o.AllowedIncrement -} - -func (o *EntityEditRule) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *EntityEditRule) GetCadencePeriod() *float64 { - if o == nil { - return nil - } - return o.CadencePeriod -} - -func (o *EntityEditRule) GetCadencePeriodType() *string { - if o == nil { - return nil - } - return o.CadencePeriodType -} - -func (o *EntityEditRule) GetChangesAllowed() *float64 { - if o == nil { - return nil - } - return o.ChangesAllowed -} - -func (o *EntityEditRule) GetGracePeriod() *float64 { - if o == nil { - return nil - } - return o.GracePeriod -} - -func (o *EntityEditRule) GetNumberOfDaysBeforeRestriction() *float64 { - if o == nil { - return nil - } - return o.NumberOfDaysBeforeRestriction -} - -func (o *EntityEditRule) GetRuleType() *string { - if o == nil { - return nil - } - return o.RuleType -} - -func (o *EntityEditRule) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} diff --git a/internal/sdk/models/shared/entityfilecount.go b/internal/sdk/models/shared/entityfilecount.go deleted file mode 100644 index ad85684..0000000 --- a/internal/sdk/models/shared/entityfilecount.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type EntityFileCount struct { - // URL-friendly identifier for the entity schema - Schema EntitySlug `json:"_schema"` - // The title of the parent entity - Title *string `json:"_title,omitempty"` - // Entity ID - EntityID string `json:"entity_id"` - // Number of files associated with the entity and shared with portal user - FileCount int64 `json:"file_count"` -} - -func (o *EntityFileCount) GetSchema() EntitySlug { - if o == nil { - return EntitySlug("") - } - return o.Schema -} - -func (o *EntityFileCount) GetTitle() *string { - if o == nil { - return nil - } - return o.Title -} - -func (o *EntityFileCount) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *EntityFileCount) GetFileCount() int64 { - if o == nil { - return 0 - } - return o.FileCount -} diff --git a/internal/sdk/models/shared/entityitem.go b/internal/sdk/models/shared/entityitem.go deleted file mode 100644 index 3a052c2..0000000 --- a/internal/sdk/models/shared/entityitem.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type EntityItem struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - // URL-friendly identifier for the entity schema - Schema EntitySlug `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (e EntityItem) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityItem) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *EntityItem) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *EntityItem) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *EntityItem) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *EntityItem) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *EntityItem) GetSchema() EntitySlug { - if o == nil { - return EntitySlug("") - } - return o.Schema -} - -func (o *EntityItem) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *EntityItem) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *EntityItem) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/entityresponsegroupedwithhits.go b/internal/sdk/models/shared/entityresponsegroupedwithhits.go deleted file mode 100644 index 84d3094..0000000 --- a/internal/sdk/models/shared/entityresponsegroupedwithhits.go +++ /dev/null @@ -1,181 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// EntityResponseGroupedWithHitsPagination - Pagination metadata for entities within this group -type EntityResponseGroupedWithHitsPagination struct { - // Starting offset for entities in this group - From *float64 `json:"from,omitempty"` - // Whether there are more entities available in this group beyond the current page - HasMore *bool `json:"has_more,omitempty"` - // Number of entities returned for this group - Size *float64 `json:"size,omitempty"` - // Total number of entities available in this group - Total *float64 `json:"total,omitempty"` -} - -func (e EntityResponseGroupedWithHitsPagination) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityResponseGroupedWithHitsPagination) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *EntityResponseGroupedWithHitsPagination) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *EntityResponseGroupedWithHitsPagination) GetHasMore() *bool { - if o == nil { - return nil - } - return o.HasMore -} - -func (o *EntityResponseGroupedWithHitsPagination) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -func (o *EntityResponseGroupedWithHitsPagination) GetTotal() *float64 { - if o == nil { - return nil - } - return o.Total -} - -type Groups struct { - // Total number of entities in this group - Count *float64 `json:"count,omitempty"` - // Group title - Group *string `json:"group,omitempty"` - // Pagination metadata for entities within this group - Pagination *EntityResponseGroupedWithHitsPagination `json:"pagination,omitempty"` - Results []EntityItem `json:"results,omitempty"` -} - -func (g Groups) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *Groups) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Groups) GetCount() *float64 { - if o == nil { - return nil - } - return o.Count -} - -func (o *Groups) GetGroup() *string { - if o == nil { - return nil - } - return o.Group -} - -func (o *Groups) GetPagination() *EntityResponseGroupedWithHitsPagination { - if o == nil { - return nil - } - return o.Pagination -} - -func (o *Groups) GetResults() []EntityItem { - if o == nil { - return nil - } - return o.Results -} - -// GroupsPagination - Group pagination metadata -type GroupsPagination struct { - // Composite aggregation key for the next page - AfterKey map[string]string `json:"after_key,omitempty"` - // Whether there are more groups available - HasMore *bool `json:"has_more,omitempty"` -} - -func (g GroupsPagination) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(g, "", false) -} - -func (g *GroupsPagination) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *GroupsPagination) GetAfterKey() map[string]string { - if o == nil { - return nil - } - return o.AfterKey -} - -func (o *GroupsPagination) GetHasMore() *bool { - if o == nil { - return nil - } - return o.HasMore -} - -// EntityResponseGroupedWithHits - Response for entity search requests, but with groupings -type EntityResponseGroupedWithHits struct { - Groups []Groups `json:"groups,omitempty"` - // Group pagination metadata - GroupsPagination *GroupsPagination `json:"groups_pagination,omitempty"` - // Number of groups returned in this response - Hits *float64 `json:"hits,omitempty"` -} - -func (e EntityResponseGroupedWithHits) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityResponseGroupedWithHits) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *EntityResponseGroupedWithHits) GetGroups() []Groups { - if o == nil { - return nil - } - return o.Groups -} - -func (o *EntityResponseGroupedWithHits) GetGroupsPagination() *GroupsPagination { - if o == nil { - return nil - } - return o.GroupsPagination -} - -func (o *EntityResponseGroupedWithHits) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} diff --git a/internal/sdk/models/shared/entityresponsewithhits.go b/internal/sdk/models/shared/entityresponsewithhits.go deleted file mode 100644 index 7333319..0000000 --- a/internal/sdk/models/shared/entityresponsewithhits.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// Pagination metadata -type Pagination struct { - // Starting offset for the current page - From *float64 `json:"from,omitempty"` - // Whether there are more entities available beyond the current page - HasMore *bool `json:"has_more,omitempty"` - // Number of entities per page - Size *float64 `json:"size,omitempty"` - // Total number of entities available - Total *float64 `json:"total,omitempty"` -} - -func (p Pagination) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *Pagination) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Pagination) GetFrom() *float64 { - if o == nil { - return nil - } - return o.From -} - -func (o *Pagination) GetHasMore() *bool { - if o == nil { - return nil - } - return o.HasMore -} - -func (o *Pagination) GetSize() *float64 { - if o == nil { - return nil - } - return o.Size -} - -func (o *Pagination) GetTotal() *float64 { - if o == nil { - return nil - } - return o.Total -} - -// EntityResponseWithHits - Response for entity search requests -type EntityResponseWithHits struct { - // Number of entities returned in this response - Hits *float64 `json:"hits,omitempty"` - // Pagination metadata - Pagination *Pagination `json:"pagination,omitempty"` - Results []EntityItem `json:"results,omitempty"` -} - -func (e EntityResponseWithHits) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityResponseWithHits) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *EntityResponseWithHits) GetHits() *float64 { - if o == nil { - return nil - } - return o.Hits -} - -func (o *EntityResponseWithHits) GetPagination() *Pagination { - if o == nil { - return nil - } - return o.Pagination -} - -func (o *EntityResponseWithHits) GetResults() []EntityItem { - if o == nil { - return nil - } - return o.Results -} diff --git a/internal/sdk/models/shared/entitysearchparams.go b/internal/sdk/models/shared/entitysearchparams.go deleted file mode 100644 index 374ac24..0000000 --- a/internal/sdk/models/shared/entitysearchparams.go +++ /dev/null @@ -1,353 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// Filters - Elasticsearch filter object -type Filters struct { -} - -type FiltersSchema string - -const ( - FiltersSchemaContact FiltersSchema = "contact" - FiltersSchemaContract FiltersSchema = "contract" - FiltersSchemaPortalUser FiltersSchema = "portal_user" -) - -func (e FiltersSchema) ToPointer() *FiltersSchema { - return &e -} -func (e *FiltersSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contact": - fallthrough - case "contract": - fallthrough - case "portal_user": - *e = FiltersSchema(v) - return nil - default: - return fmt.Errorf("invalid value for FiltersSchema: %v", v) - } -} - -type GroupAfterKeyType string - -const ( - GroupAfterKeyTypeStr GroupAfterKeyType = "str" - GroupAfterKeyTypeNumber GroupAfterKeyType = "number" -) - -type GroupAfterKey struct { - Str *string `queryParam:"inline" name:"group_after_key"` - Number *float64 `queryParam:"inline" name:"group_after_key"` - - Type GroupAfterKeyType -} - -func CreateGroupAfterKeyStr(str string) GroupAfterKey { - typ := GroupAfterKeyTypeStr - - return GroupAfterKey{ - Str: &str, - Type: typ, - } -} - -func CreateGroupAfterKeyNumber(number float64) GroupAfterKey { - typ := GroupAfterKeyTypeNumber - - return GroupAfterKey{ - Number: &number, - Type: typ, - } -} - -func (u *GroupAfterKey) UnmarshalJSON(data []byte) error { - - var str string = "" - if err := utils.UnmarshalJSON(data, &str, "", true, nil); err == nil { - u.Str = &str - u.Type = GroupAfterKeyTypeStr - return nil - } - - var number float64 = float64(0) - if err := utils.UnmarshalJSON(data, &number, "", true, nil); err == nil { - u.Number = &number - u.Type = GroupAfterKeyTypeNumber - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for GroupAfterKey", string(data)) -} - -func (u GroupAfterKey) MarshalJSON() ([]byte, error) { - if u.Str != nil { - return utils.MarshalJSON(u.Str, "", true) - } - - if u.Number != nil { - return utils.MarshalJSON(u.Number, "", true) - } - - return nil, errors.New("could not marshal union type GroupAfterKey: all fields are null") -} - -// GroupSort - Sort order for groups -type GroupSort string - -const ( - GroupSortAsc GroupSort = "asc" - GroupSortDesc GroupSort = "desc" -) - -func (e GroupSort) ToPointer() *GroupSort { - return &e -} -func (e *GroupSort) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "asc": - fallthrough - case "desc": - *e = GroupSort(v) - return nil - default: - return fmt.Errorf("invalid value for GroupSort: %v", v) - } -} - -type SlugType string - -const ( - SlugTypeEntitySlug SlugType = "EntitySlug" - SlugTypeArrayOfEntitySlug SlugType = "arrayOfEntitySlug" -) - -// Slug - Single entity schema slug or array of slugs -type Slug struct { - EntitySlug *EntitySlug `queryParam:"inline" name:"slug"` - ArrayOfEntitySlug []EntitySlug `queryParam:"inline" name:"slug"` - - Type SlugType -} - -func CreateSlugEntitySlug(entitySlug EntitySlug) Slug { - typ := SlugTypeEntitySlug - - return Slug{ - EntitySlug: &entitySlug, - Type: typ, - } -} - -func CreateSlugArrayOfEntitySlug(arrayOfEntitySlug []EntitySlug) Slug { - typ := SlugTypeArrayOfEntitySlug - - return Slug{ - ArrayOfEntitySlug: arrayOfEntitySlug, - Type: typ, - } -} - -func (u *Slug) UnmarshalJSON(data []byte) error { - - var entitySlug EntitySlug = EntitySlug("") - if err := utils.UnmarshalJSON(data, &entitySlug, "", true, nil); err == nil { - u.EntitySlug = &entitySlug - u.Type = SlugTypeEntitySlug - return nil - } - - var arrayOfEntitySlug []EntitySlug = []EntitySlug{} - if err := utils.UnmarshalJSON(data, &arrayOfEntitySlug, "", true, nil); err == nil { - u.ArrayOfEntitySlug = arrayOfEntitySlug - u.Type = SlugTypeArrayOfEntitySlug - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for Slug", string(data)) -} - -func (u Slug) MarshalJSON() ([]byte, error) { - if u.EntitySlug != nil { - return utils.MarshalJSON(u.EntitySlug, "", true) - } - - if u.ArrayOfEntitySlug != nil { - return utils.MarshalJSON(u.ArrayOfEntitySlug, "", true) - } - - return nil, errors.New("could not marshal union type Slug: all fields are null") -} - -type EntitySearchParams struct { - // List of contract IDs to filter by - Contracts []string `json:"contracts,omitempty"` - // List of entity fields to include in search results - Fields []string `json:"fields,omitempty"` - // Additional filters to apply to the search query - Filters []Filters `json:"filters,omitempty"` - // Schema-based filters for entity relations. - FiltersSchema []FiltersSchema `json:"filters_schema,omitempty"` - From *int64 `default:"0" json:"from"` - // Field to group results by - Group *string `json:"group,omitempty"` - // Composite aggregation key for group pagination - GroupAfterKey map[string]GroupAfterKey `json:"group_after_key,omitempty"` - // Number of groups to return - GroupSize *int64 `default:"100" json:"group_size"` - // Sort order for groups - GroupSort *GroupSort `default:"asc" json:"group_sort"` - // When true, enables entity hydration to resolve nested $relation & $relation_ref references in-place. - Hydrate *bool `default:"false" json:"hydrate"` - // Keyword search query - Q *string `json:"q,omitempty"` - // List of fields that can be searched - QFields []string `json:"q_fields,omitempty"` - // Max search size is 1000 with higher values defaulting to 1000 - Size *int64 `default:"100" json:"size"` - // Single entity schema slug or array of slugs - Slug Slug `json:"slug"` - Sort *string `json:"sort,omitempty"` - // Filters from these targets will be applied to the search query. - Targets []string `json:"targets,omitempty"` -} - -func (e EntitySearchParams) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntitySearchParams) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"slug"}); err != nil { - return err - } - return nil -} - -func (o *EntitySearchParams) GetContracts() []string { - if o == nil { - return nil - } - return o.Contracts -} - -func (o *EntitySearchParams) GetFields() []string { - if o == nil { - return nil - } - return o.Fields -} - -func (o *EntitySearchParams) GetFilters() []Filters { - if o == nil { - return nil - } - return o.Filters -} - -func (o *EntitySearchParams) GetFiltersSchema() []FiltersSchema { - if o == nil { - return nil - } - return o.FiltersSchema -} - -func (o *EntitySearchParams) GetFrom() *int64 { - if o == nil { - return nil - } - return o.From -} - -func (o *EntitySearchParams) GetGroup() *string { - if o == nil { - return nil - } - return o.Group -} - -func (o *EntitySearchParams) GetGroupAfterKey() map[string]GroupAfterKey { - if o == nil { - return nil - } - return o.GroupAfterKey -} - -func (o *EntitySearchParams) GetGroupSize() *int64 { - if o == nil { - return nil - } - return o.GroupSize -} - -func (o *EntitySearchParams) GetGroupSort() *GroupSort { - if o == nil { - return nil - } - return o.GroupSort -} - -func (o *EntitySearchParams) GetHydrate() *bool { - if o == nil { - return nil - } - return o.Hydrate -} - -func (o *EntitySearchParams) GetQ() *string { - if o == nil { - return nil - } - return o.Q -} - -func (o *EntitySearchParams) GetQFields() []string { - if o == nil { - return nil - } - return o.QFields -} - -func (o *EntitySearchParams) GetSize() *int64 { - if o == nil { - return nil - } - return o.Size -} - -func (o *EntitySearchParams) GetSlug() Slug { - if o == nil { - return Slug{} - } - return o.Slug -} - -func (o *EntitySearchParams) GetSort() *string { - if o == nil { - return nil - } - return o.Sort -} - -func (o *EntitySearchParams) GetTargets() []string { - if o == nil { - return nil - } - return o.Targets -} diff --git a/internal/sdk/models/shared/entityslug.go b/internal/sdk/models/shared/entityslug.go deleted file mode 100644 index 66063d3..0000000 --- a/internal/sdk/models/shared/entityslug.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -// EntitySlug - URL-friendly identifier for the entity schema -type EntitySlug string - -const ( - EntitySlugContact EntitySlug = "contact" - EntitySlugContract EntitySlug = "contract" - EntitySlugFile EntitySlug = "file" - EntitySlugOrder EntitySlug = "order" - EntitySlugOpportunity EntitySlug = "opportunity" - EntitySlugProduct EntitySlug = "product" - EntitySlugPrice EntitySlug = "price" - EntitySlugMeter EntitySlug = "meter" - EntitySlugMeterCounter EntitySlug = "meter_counter" -) - -func (e EntitySlug) ToPointer() *EntitySlug { - return &e -} -func (e *EntitySlug) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contact": - fallthrough - case "contract": - fallthrough - case "file": - fallthrough - case "order": - fallthrough - case "opportunity": - fallthrough - case "product": - fallthrough - case "price": - fallthrough - case "meter": - fallthrough - case "meter_counter": - *e = EntitySlug(v) - return nil - default: - return fmt.Errorf("invalid value for EntitySlug: %v", v) - } -} diff --git a/internal/sdk/models/shared/entitywidget.go b/internal/sdk/models/shared/entitywidget.go deleted file mode 100644 index 2cbfcbb..0000000 --- a/internal/sdk/models/shared/entitywidget.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type EntityWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (e EntityWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *EntityWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *EntityWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type EntityWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (e EntityWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *EntityWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *EntityWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type EntityWidgetType string - -const ( - EntityWidgetTypeActionWidget EntityWidgetType = "ACTION_WIDGET" - EntityWidgetTypeContentWidget EntityWidgetType = "CONTENT_WIDGET" - EntityWidgetTypeEntityWidget EntityWidgetType = "ENTITY_WIDGET" - EntityWidgetTypeTeaserWidget EntityWidgetType = "TEASER_WIDGET" - EntityWidgetTypeDocumentWidget EntityWidgetType = "DOCUMENT_WIDGET" - EntityWidgetTypePaymentWidget EntityWidgetType = "PAYMENT_WIDGET" - EntityWidgetTypeMeterReadingWidget EntityWidgetType = "METER_READING_WIDGET" - EntityWidgetTypeMeterChartWidget EntityWidgetType = "METER_CHART_WIDGET" - EntityWidgetTypeCampaignWidget EntityWidgetType = "CAMPAIGN_WIDGET" -) - -func (e EntityWidgetType) ToPointer() *EntityWidgetType { - return &e -} -func (e *EntityWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = EntityWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for EntityWidgetType: %v", v) - } -} - -type EntityWidget struct { - Headline *EntityWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - Schema *string `json:"schema,omitempty"` - SubHeadline *EntityWidgetSubHeadline `json:"subHeadline,omitempty"` - Type EntityWidgetType `json:"type"` -} - -func (e EntityWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *EntityWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *EntityWidget) GetHeadline() *EntityWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *EntityWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *EntityWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *EntityWidget) GetSchema() *string { - if o == nil { - return nil - } - return o.Schema -} - -func (o *EntityWidget) GetSubHeadline() *EntityWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *EntityWidget) GetType() EntityWidgetType { - if o == nil { - return EntityWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/equalscondition.go b/internal/sdk/models/shared/equalscondition.go new file mode 100644 index 0000000..faaab32 --- /dev/null +++ b/internal/sdk/models/shared/equalscondition.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" +) + +type Operation string + +const ( + OperationEquals Operation = "equals" +) + +func (e Operation) ToPointer() *Operation { + return &e +} +func (e *Operation) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "equals": + *e = Operation(v) + return nil + default: + return fmt.Errorf("invalid value for Operation: %v", v) + } +} + +// EqualsCondition - Check if attribute equals to any of the values +type EqualsCondition struct { + Attribute string `json:"attribute"` + Operation Operation `json:"operation"` + Values []any `json:"values"` +} + +func (e EqualsCondition) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EqualsCondition) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, []string{"attribute", "operation", "values"}); err != nil { + return err + } + return nil +} + +func (e *EqualsCondition) GetAttribute() string { + if e == nil { + return "" + } + return e.Attribute +} + +func (e *EqualsCondition) GetOperation() Operation { + if e == nil { + return Operation("") + } + return e.Operation +} + +func (e *EqualsCondition) GetValues() []any { + if e == nil { + return []any{} + } + return e.Values +} diff --git a/internal/sdk/models/shared/errorresp.go b/internal/sdk/models/shared/errorresp.go deleted file mode 100644 index ea9a81d..0000000 --- a/internal/sdk/models/shared/errorresp.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// ErrorResp - Could not authenticate the user -type ErrorResp struct { - // Error message - Message *string `json:"message,omitempty"` -} - -func (e ErrorResp) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ErrorResp) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *ErrorResp) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} diff --git a/internal/sdk/models/shared/extension.go b/internal/sdk/models/shared/extension.go deleted file mode 100644 index 51f4781..0000000 --- a/internal/sdk/models/shared/extension.go +++ /dev/null @@ -1,1410 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// Description - Name of the extension. -type Description struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (d Description) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(d, "", false) -} - -func (d *Description) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &d, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *Description) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Description) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type SchemasExtensionHookMeterReadingPlausibilityCheckCall struct { - // JSON body to use for the call. Supports variable interpolation. - Body map[string]string `json:"body"` - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (s SchemasExtensionHookMeterReadingPlausibilityCheckCall) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookMeterReadingPlausibilityCheckCall) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"body", "headers", "url"}); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckCall) GetBody() map[string]string { - if o == nil { - return map[string]string{} - } - return o.Body -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckCall) GetHeaders() map[string]string { - if o == nil { - return map[string]string{} - } - return o.Headers -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckCall) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -// SchemasExtensionHookMeterReadingPlausibilityCheckResolved - Response to the call -type SchemasExtensionHookMeterReadingPlausibilityCheckResolved struct { - // Lower allowed limit of the meter reading - LowerLimit *string `json:"lower_limit,omitempty"` - // Upper allowed limit of the meter reading - UpperLimit *string `json:"upper_limit,omitempty"` - // Indicate whether the meter reading is plausible - Valid *string `json:"valid,omitempty"` -} - -func (s SchemasExtensionHookMeterReadingPlausibilityCheckResolved) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookMeterReadingPlausibilityCheckResolved) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckResolved) GetLowerLimit() *string { - if o == nil { - return nil - } - return o.LowerLimit -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckResolved) GetUpperLimit() *string { - if o == nil { - return nil - } - return o.UpperLimit -} - -func (o *SchemasExtensionHookMeterReadingPlausibilityCheckResolved) GetValid() *string { - if o == nil { - return nil - } - return o.Valid -} - -type SchemasExtensionHookMeterReadingPlausibilityCheckType string - -const ( - SchemasExtensionHookMeterReadingPlausibilityCheckTypeMeterReadingPlausibilityCheck SchemasExtensionHookMeterReadingPlausibilityCheckType = "meterReadingPlausibilityCheck" -) - -func (e SchemasExtensionHookMeterReadingPlausibilityCheckType) ToPointer() *SchemasExtensionHookMeterReadingPlausibilityCheckType { - return &e -} -func (e *SchemasExtensionHookMeterReadingPlausibilityCheckType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "meterReadingPlausibilityCheck": - *e = SchemasExtensionHookMeterReadingPlausibilityCheckType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasExtensionHookMeterReadingPlausibilityCheckType: %v", v) - } -} - -// ExtensionHookMeterReadingPlausibilityCheckSchemas - Hook that checks the plausibility of meter readings before they are saved. This hook makes a POST call whenever a user is trying to save a meter reading. The expected response to the call is: -// -// - 200: -// If meter reading is plausible, the response should contain: -// - valid: true -// If meter reading is not plausible, the response should contain: -// - valid: false -type ExtensionHookMeterReadingPlausibilityCheckSchemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call SchemasExtensionHookMeterReadingPlausibilityCheckCall `json:"call"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - // Response to the call - Resolved SchemasExtensionHookMeterReadingPlausibilityCheckResolved `json:"resolved"` - Type SchemasExtensionHookMeterReadingPlausibilityCheckType `json:"type"` -} - -func (e ExtensionHookMeterReadingPlausibilityCheckSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionHookMeterReadingPlausibilityCheckSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"call", "resolved", "type"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionHookMeterReadingPlausibilityCheckSchemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionHookMeterReadingPlausibilityCheckSchemas) GetCall() SchemasExtensionHookMeterReadingPlausibilityCheckCall { - if o == nil { - return SchemasExtensionHookMeterReadingPlausibilityCheckCall{} - } - return o.Call -} - -func (o *ExtensionHookMeterReadingPlausibilityCheckSchemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ExtensionHookMeterReadingPlausibilityCheckSchemas) GetResolved() SchemasExtensionHookMeterReadingPlausibilityCheckResolved { - if o == nil { - return SchemasExtensionHookMeterReadingPlausibilityCheckResolved{} - } - return o.Resolved -} - -func (o *ExtensionHookMeterReadingPlausibilityCheckSchemas) GetType() SchemasExtensionHookMeterReadingPlausibilityCheckType { - if o == nil { - return SchemasExtensionHookMeterReadingPlausibilityCheckType("") - } - return o.Type -} - -type SchemasExtensionHookCostDataRetrievalCall struct { - // Request body to send. Supports variable interpolation. Content format is determined by Content-Type header. - Body map[string]string `json:"body,omitempty"` - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers,omitempty"` - // HTTP method to use for the call - Method *string `default:"GET" json:"method"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (s SchemasExtensionHookCostDataRetrievalCall) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookCostDataRetrievalCall) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"url"}); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookCostDataRetrievalCall) GetBody() map[string]string { - if o == nil { - return nil - } - return o.Body -} - -func (o *SchemasExtensionHookCostDataRetrievalCall) GetHeaders() map[string]string { - if o == nil { - return nil - } - return o.Headers -} - -func (o *SchemasExtensionHookCostDataRetrievalCall) GetMethod() *string { - if o == nil { - return nil - } - return o.Method -} - -func (o *SchemasExtensionHookCostDataRetrievalCall) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *SchemasExtensionHookCostDataRetrievalCall) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -type SchemasResolved struct { - // Optional path to the data (array) in the response. If omitted, the data is assumed to be on the top level. - DataPath *string `json:"dataPath,omitempty"` -} - -func (s SchemasResolved) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasResolved) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasResolved) GetDataPath() *string { - if o == nil { - return nil - } - return o.DataPath -} - -type SchemasExtensionHookCostDataRetrievalType string - -const ( - SchemasExtensionHookCostDataRetrievalTypeCostDataRetrieval SchemasExtensionHookCostDataRetrievalType = "costDataRetrieval" -) - -func (e SchemasExtensionHookCostDataRetrievalType) ToPointer() *SchemasExtensionHookCostDataRetrievalType { - return &e -} -func (e *SchemasExtensionHookCostDataRetrievalType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "costDataRetrieval": - *e = SchemasExtensionHookCostDataRetrievalType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasExtensionHookCostDataRetrievalType: %v", v) - } -} - -// ExtensionHookCostDataRetrievalSchemas - Hook that will allow using the specified source as data for consumption visualizations. This hook is triggered to fetch the data. Format of the request and response has to follow the following specification: TBD. The expected response to the call is: -// -// - 200 with the time series data -type ExtensionHookCostDataRetrievalSchemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call SchemasExtensionHookCostDataRetrievalCall `json:"call"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - Resolved *SchemasResolved `json:"resolved,omitempty"` - Type SchemasExtensionHookCostDataRetrievalType `json:"type"` -} - -func (e ExtensionHookCostDataRetrievalSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionHookCostDataRetrievalSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"call", "type"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionHookCostDataRetrievalSchemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionHookCostDataRetrievalSchemas) GetCall() SchemasExtensionHookCostDataRetrievalCall { - if o == nil { - return SchemasExtensionHookCostDataRetrievalCall{} - } - return o.Call -} - -func (o *ExtensionHookCostDataRetrievalSchemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ExtensionHookCostDataRetrievalSchemas) GetResolved() *SchemasResolved { - if o == nil { - return nil - } - return o.Resolved -} - -func (o *ExtensionHookCostDataRetrievalSchemas) GetType() SchemasExtensionHookCostDataRetrievalType { - if o == nil { - return SchemasExtensionHookCostDataRetrievalType("") - } - return o.Type -} - -type Call struct { - // Request body to send. Supports variable interpolation. Content format is determined by Content-Type header. - Body map[string]string `json:"body,omitempty"` - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers,omitempty"` - // HTTP method to use for the call - Method *string `default:"GET" json:"method"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (c Call) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(c, "", false) -} - -func (c *Call) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &c, "", false, []string{"url"}); err != nil { - return err - } - return nil -} - -func (o *Call) GetBody() map[string]string { - if o == nil { - return nil - } - return o.Body -} - -func (o *Call) GetHeaders() map[string]string { - if o == nil { - return nil - } - return o.Headers -} - -func (o *Call) GetMethod() *string { - if o == nil { - return nil - } - return o.Method -} - -func (o *Call) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *Call) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -type Resolved struct { - // Optional path to the data (array) in the response. If omitted, the data is assumed to be on the top level. - DataPath *string `json:"dataPath,omitempty"` -} - -func (r Resolved) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(r, "", false) -} - -func (r *Resolved) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Resolved) GetDataPath() *string { - if o == nil { - return nil - } - return o.DataPath -} - -type Type string - -const ( - TypeConsumptionDataRetrieval Type = "consumptionDataRetrieval" -) - -func (e Type) ToPointer() *Type { - return &e -} -func (e *Type) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "consumptionDataRetrieval": - *e = Type(v) - return nil - default: - return fmt.Errorf("invalid value for Type: %v", v) - } -} - -// Schemas - Hook that will allow using the specified source as data for consumption visualizations. This hook is triggered to fetch the data. Format of the request and response has to follow the following specification: TBD. The expected response to the call is: -// -// - 200 with the time series data -type Schemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call Call `json:"call"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - Resolved *Resolved `json:"resolved,omitempty"` - Type Type `json:"type"` -} - -func (s Schemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *Schemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"call", "type"}); err != nil { - return err - } - return nil -} - -func (o *Schemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *Schemas) GetCall() Call { - if o == nil { - return Call{} - } - return o.Call -} - -func (o *Schemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *Schemas) GetResolved() *Resolved { - if o == nil { - return nil - } - return o.Resolved -} - -func (o *Schemas) GetType() Type { - if o == nil { - return Type("") - } - return o.Type -} - -type SchemasExtensionHookPriceDataRetrievalCall struct { - // Request body to send. Supports variable interpolation. Content format is determined by Content-Type header. - Body map[string]string `json:"body,omitempty"` - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers,omitempty"` - // HTTP method to use for the call - Method *string `default:"GET" json:"method"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (s SchemasExtensionHookPriceDataRetrievalCall) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookPriceDataRetrievalCall) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"url"}); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookPriceDataRetrievalCall) GetBody() map[string]string { - if o == nil { - return nil - } - return o.Body -} - -func (o *SchemasExtensionHookPriceDataRetrievalCall) GetHeaders() map[string]string { - if o == nil { - return nil - } - return o.Headers -} - -func (o *SchemasExtensionHookPriceDataRetrievalCall) GetMethod() *string { - if o == nil { - return nil - } - return o.Method -} - -func (o *SchemasExtensionHookPriceDataRetrievalCall) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *SchemasExtensionHookPriceDataRetrievalCall) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -type SchemasExtensionHookPriceDataRetrievalResolved struct { - // Optional path to the data (array) in the response. If omitted, the data is assumed to be on the top level. - DataPath *string `json:"dataPath,omitempty"` -} - -func (s SchemasExtensionHookPriceDataRetrievalResolved) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookPriceDataRetrievalResolved) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookPriceDataRetrievalResolved) GetDataPath() *string { - if o == nil { - return nil - } - return o.DataPath -} - -type SchemasExtensionHookPriceDataRetrievalType string - -const ( - SchemasExtensionHookPriceDataRetrievalTypePriceDataRetrieval SchemasExtensionHookPriceDataRetrievalType = "priceDataRetrieval" -) - -func (e SchemasExtensionHookPriceDataRetrievalType) ToPointer() *SchemasExtensionHookPriceDataRetrievalType { - return &e -} -func (e *SchemasExtensionHookPriceDataRetrievalType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "priceDataRetrieval": - *e = SchemasExtensionHookPriceDataRetrievalType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasExtensionHookPriceDataRetrievalType: %v", v) - } -} - -// ExtensionHookPriceDataRetrievalSchemas - Hook that will allow using the specified source as data for price visualizations. This hook is triggered to fetch the data. Format of the request and response has to follow the following specification: TBD. The expected response to the call is: -// -// - 200 with the time series data -type ExtensionHookPriceDataRetrievalSchemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call SchemasExtensionHookPriceDataRetrievalCall `json:"call"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - Resolved *SchemasExtensionHookPriceDataRetrievalResolved `json:"resolved,omitempty"` - Type SchemasExtensionHookPriceDataRetrievalType `json:"type"` -} - -func (e ExtensionHookPriceDataRetrievalSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionHookPriceDataRetrievalSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"call", "type"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionHookPriceDataRetrievalSchemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionHookPriceDataRetrievalSchemas) GetCall() SchemasExtensionHookPriceDataRetrievalCall { - if o == nil { - return SchemasExtensionHookPriceDataRetrievalCall{} - } - return o.Call -} - -func (o *ExtensionHookPriceDataRetrievalSchemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ExtensionHookPriceDataRetrievalSchemas) GetResolved() *SchemasExtensionHookPriceDataRetrievalResolved { - if o == nil { - return nil - } - return o.Resolved -} - -func (o *ExtensionHookPriceDataRetrievalSchemas) GetType() SchemasExtensionHookPriceDataRetrievalType { - if o == nil { - return SchemasExtensionHookPriceDataRetrievalType("") - } - return o.Type -} - -type SchemasCall struct { - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (s SchemasCall) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasCall) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"headers", "url"}); err != nil { - return err - } - return nil -} - -func (o *SchemasCall) GetHeaders() map[string]string { - if o == nil { - return map[string]string{} - } - return o.Headers -} - -func (o *SchemasCall) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *SchemasCall) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -// Explanation of the hook. -type Explanation struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Explanation of the functionality shown to the end user. - En string `json:"en"` -} - -func (e Explanation) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *Explanation) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *Explanation) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Explanation) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type SchemasType string - -const ( - SchemasTypeContractIdentification SchemasType = "contractIdentification" -) - -func (e SchemasType) ToPointer() *SchemasType { - return &e -} -func (e *SchemasType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contractIdentification": - *e = SchemasType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasType: %v", v) - } -} - -// ExtensionHookContractIdentificationSchemas - Hook that replaces the built-in contract identification for self-assignment. This hook makes a POST call whenever a user is trying to self-assign a contract to find the corresponding contract(s). The expected response to the call is: -// -// - 200 if found with either: -// - contract_id array -// - contact_id string -// - 404 if no contract is found -// -// If `contact_id` is provided in the response, Contracts are retrieved from this Contact. In that case, optionally, if you also specify `contact_relation_attribute`, the specified Contact attribute of the user performing the action will be modified to add the matched Contact. -type ExtensionHookContractIdentificationSchemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call SchemasCall `json:"call"` - // Name of the Contact attribute to update with the matched Contact ID. Must be a Contact relation attribute supporting multiple entities. - ContactRelationAttribute *string `json:"contact_relation_attribute,omitempty"` - // Explanation of the hook. - Explanation *Explanation `json:"explanation,omitempty"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - Type SchemasType `json:"type"` -} - -func (e ExtensionHookContractIdentificationSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionHookContractIdentificationSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"call", "type"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionHookContractIdentificationSchemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionHookContractIdentificationSchemas) GetCall() SchemasCall { - if o == nil { - return SchemasCall{} - } - return o.Call -} - -func (o *ExtensionHookContractIdentificationSchemas) GetContactRelationAttribute() *string { - if o == nil { - return nil - } - return o.ContactRelationAttribute -} - -func (o *ExtensionHookContractIdentificationSchemas) GetExplanation() *Explanation { - if o == nil { - return nil - } - return o.Explanation -} - -func (o *ExtensionHookContractIdentificationSchemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ExtensionHookContractIdentificationSchemas) GetType() SchemasType { - if o == nil { - return SchemasType("") - } - return o.Type -} - -type SchemasExtensionHookRegistrationIdentifiersCheckCall struct { - // Headers to use. Supports variable interpolation. - Headers map[string]string `json:"headers"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // Contact ID usually retrieved from the response body, e.g. `{{"{{"}}CallResponse.data.contact_id}}`. Supports variable interpolation. - Result string `json:"result"` - // URL to call. Supports variable interpolation. - URL string `json:"url"` -} - -func (s SchemasExtensionHookRegistrationIdentifiersCheckCall) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *SchemasExtensionHookRegistrationIdentifiersCheckCall) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, []string{"headers", "result", "url"}); err != nil { - return err - } - return nil -} - -func (o *SchemasExtensionHookRegistrationIdentifiersCheckCall) GetHeaders() map[string]string { - if o == nil { - return map[string]string{} - } - return o.Headers -} - -func (o *SchemasExtensionHookRegistrationIdentifiersCheckCall) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *SchemasExtensionHookRegistrationIdentifiersCheckCall) GetResult() string { - if o == nil { - return "" - } - return o.Result -} - -func (o *SchemasExtensionHookRegistrationIdentifiersCheckCall) GetURL() string { - if o == nil { - return "" - } - return o.URL -} - -type SchemasExtensionHookRegistrationIdentifiersCheckType string - -const ( - SchemasExtensionHookRegistrationIdentifiersCheckTypeRegistrationIdentifiersCheck SchemasExtensionHookRegistrationIdentifiersCheckType = "registrationIdentifiersCheck" -) - -func (e SchemasExtensionHookRegistrationIdentifiersCheckType) ToPointer() *SchemasExtensionHookRegistrationIdentifiersCheckType { - return &e -} -func (e *SchemasExtensionHookRegistrationIdentifiersCheckType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "registrationIdentifiersCheck": - *e = SchemasExtensionHookRegistrationIdentifiersCheckType(v) - return nil - default: - return fmt.Errorf("invalid value for SchemasExtensionHookRegistrationIdentifiersCheckType: %v", v) - } -} - -// ExtensionHookRegistrationIdentifiersCheckSchemas - Hook that replaces the built-in registration identifiers check. This hook makes a POST call whenever a user is trying to register to find the corresponding contact. The expected response to the call is: -// -// - 200 with contact id if exactly one contact is found -// - 404 if no contact is found or more than contact is found -type ExtensionHookRegistrationIdentifiersCheckSchemas struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - Call SchemasExtensionHookRegistrationIdentifiersCheckCall `json:"call"` - // Identifier of the hook. Should not change between updates. - ID *string `json:"id,omitempty"` - Type SchemasExtensionHookRegistrationIdentifiersCheckType `json:"type"` -} - -func (e ExtensionHookRegistrationIdentifiersCheckSchemas) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionHookRegistrationIdentifiersCheckSchemas) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"call", "type"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionHookRegistrationIdentifiersCheckSchemas) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionHookRegistrationIdentifiersCheckSchemas) GetCall() SchemasExtensionHookRegistrationIdentifiersCheckCall { - if o == nil { - return SchemasExtensionHookRegistrationIdentifiersCheckCall{} - } - return o.Call -} - -func (o *ExtensionHookRegistrationIdentifiersCheckSchemas) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *ExtensionHookRegistrationIdentifiersCheckSchemas) GetType() SchemasExtensionHookRegistrationIdentifiersCheckType { - if o == nil { - return SchemasExtensionHookRegistrationIdentifiersCheckType("") - } - return o.Type -} - -type HooksType string - -const ( - HooksTypeExtensionHookRegistrationIdentifiersCheckSchemas HooksType = "ExtensionHookRegistrationIdentifiersCheck_Schemas" - HooksTypeExtensionHookContractIdentificationSchemas HooksType = "ExtensionHookContractIdentification_Schemas" - HooksTypeExtensionHookPriceDataRetrievalSchemas HooksType = "ExtensionHookPriceDataRetrieval_Schemas" - HooksTypeSchemas HooksType = "Schemas" - HooksTypeExtensionHookCostDataRetrievalSchemas HooksType = "ExtensionHookCostDataRetrieval_Schemas" - HooksTypeExtensionHookMeterReadingPlausibilityCheckSchemas HooksType = "ExtensionHookMeterReadingPlausibilityCheck_Schemas" -) - -type Hooks struct { - ExtensionHookRegistrationIdentifiersCheckSchemas *ExtensionHookRegistrationIdentifiersCheckSchemas `queryParam:"inline" name:"hooks"` - ExtensionHookContractIdentificationSchemas *ExtensionHookContractIdentificationSchemas `queryParam:"inline" name:"hooks"` - ExtensionHookPriceDataRetrievalSchemas *ExtensionHookPriceDataRetrievalSchemas `queryParam:"inline" name:"hooks"` - Schemas *Schemas `queryParam:"inline" name:"hooks"` - ExtensionHookCostDataRetrievalSchemas *ExtensionHookCostDataRetrievalSchemas `queryParam:"inline" name:"hooks"` - ExtensionHookMeterReadingPlausibilityCheckSchemas *ExtensionHookMeterReadingPlausibilityCheckSchemas `queryParam:"inline" name:"hooks"` - - Type HooksType -} - -func CreateHooksExtensionHookRegistrationIdentifiersCheckSchemas(extensionHookRegistrationIdentifiersCheckSchemas ExtensionHookRegistrationIdentifiersCheckSchemas) Hooks { - typ := HooksTypeExtensionHookRegistrationIdentifiersCheckSchemas - - return Hooks{ - ExtensionHookRegistrationIdentifiersCheckSchemas: &extensionHookRegistrationIdentifiersCheckSchemas, - Type: typ, - } -} - -func CreateHooksExtensionHookContractIdentificationSchemas(extensionHookContractIdentificationSchemas ExtensionHookContractIdentificationSchemas) Hooks { - typ := HooksTypeExtensionHookContractIdentificationSchemas - - return Hooks{ - ExtensionHookContractIdentificationSchemas: &extensionHookContractIdentificationSchemas, - Type: typ, - } -} - -func CreateHooksExtensionHookPriceDataRetrievalSchemas(extensionHookPriceDataRetrievalSchemas ExtensionHookPriceDataRetrievalSchemas) Hooks { - typ := HooksTypeExtensionHookPriceDataRetrievalSchemas - - return Hooks{ - ExtensionHookPriceDataRetrievalSchemas: &extensionHookPriceDataRetrievalSchemas, - Type: typ, - } -} - -func CreateHooksSchemas(schemas Schemas) Hooks { - typ := HooksTypeSchemas - - return Hooks{ - Schemas: &schemas, - Type: typ, - } -} - -func CreateHooksExtensionHookCostDataRetrievalSchemas(extensionHookCostDataRetrievalSchemas ExtensionHookCostDataRetrievalSchemas) Hooks { - typ := HooksTypeExtensionHookCostDataRetrievalSchemas - - return Hooks{ - ExtensionHookCostDataRetrievalSchemas: &extensionHookCostDataRetrievalSchemas, - Type: typ, - } -} - -func CreateHooksExtensionHookMeterReadingPlausibilityCheckSchemas(extensionHookMeterReadingPlausibilityCheckSchemas ExtensionHookMeterReadingPlausibilityCheckSchemas) Hooks { - typ := HooksTypeExtensionHookMeterReadingPlausibilityCheckSchemas - - return Hooks{ - ExtensionHookMeterReadingPlausibilityCheckSchemas: &extensionHookMeterReadingPlausibilityCheckSchemas, - Type: typ, - } -} - -func (u *Hooks) UnmarshalJSON(data []byte) error { - - var extensionHookMeterReadingPlausibilityCheckSchemas ExtensionHookMeterReadingPlausibilityCheckSchemas = ExtensionHookMeterReadingPlausibilityCheckSchemas{} - if err := utils.UnmarshalJSON(data, &extensionHookMeterReadingPlausibilityCheckSchemas, "", true, nil); err == nil { - u.ExtensionHookMeterReadingPlausibilityCheckSchemas = &extensionHookMeterReadingPlausibilityCheckSchemas - u.Type = HooksTypeExtensionHookMeterReadingPlausibilityCheckSchemas - return nil - } - - var extensionHookRegistrationIdentifiersCheckSchemas ExtensionHookRegistrationIdentifiersCheckSchemas = ExtensionHookRegistrationIdentifiersCheckSchemas{} - if err := utils.UnmarshalJSON(data, &extensionHookRegistrationIdentifiersCheckSchemas, "", true, nil); err == nil { - u.ExtensionHookRegistrationIdentifiersCheckSchemas = &extensionHookRegistrationIdentifiersCheckSchemas - u.Type = HooksTypeExtensionHookRegistrationIdentifiersCheckSchemas - return nil - } - - var extensionHookContractIdentificationSchemas ExtensionHookContractIdentificationSchemas = ExtensionHookContractIdentificationSchemas{} - if err := utils.UnmarshalJSON(data, &extensionHookContractIdentificationSchemas, "", true, nil); err == nil { - u.ExtensionHookContractIdentificationSchemas = &extensionHookContractIdentificationSchemas - u.Type = HooksTypeExtensionHookContractIdentificationSchemas - return nil - } - - var extensionHookPriceDataRetrievalSchemas ExtensionHookPriceDataRetrievalSchemas = ExtensionHookPriceDataRetrievalSchemas{} - if err := utils.UnmarshalJSON(data, &extensionHookPriceDataRetrievalSchemas, "", true, nil); err == nil { - u.ExtensionHookPriceDataRetrievalSchemas = &extensionHookPriceDataRetrievalSchemas - u.Type = HooksTypeExtensionHookPriceDataRetrievalSchemas - return nil - } - - var schemas Schemas = Schemas{} - if err := utils.UnmarshalJSON(data, &schemas, "", true, nil); err == nil { - u.Schemas = &schemas - u.Type = HooksTypeSchemas - return nil - } - - var extensionHookCostDataRetrievalSchemas ExtensionHookCostDataRetrievalSchemas = ExtensionHookCostDataRetrievalSchemas{} - if err := utils.UnmarshalJSON(data, &extensionHookCostDataRetrievalSchemas, "", true, nil); err == nil { - u.ExtensionHookCostDataRetrievalSchemas = &extensionHookCostDataRetrievalSchemas - u.Type = HooksTypeExtensionHookCostDataRetrievalSchemas - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for Hooks", string(data)) -} - -func (u Hooks) MarshalJSON() ([]byte, error) { - if u.ExtensionHookRegistrationIdentifiersCheckSchemas != nil { - return utils.MarshalJSON(u.ExtensionHookRegistrationIdentifiersCheckSchemas, "", true) - } - - if u.ExtensionHookContractIdentificationSchemas != nil { - return utils.MarshalJSON(u.ExtensionHookContractIdentificationSchemas, "", true) - } - - if u.ExtensionHookPriceDataRetrievalSchemas != nil { - return utils.MarshalJSON(u.ExtensionHookPriceDataRetrievalSchemas, "", true) - } - - if u.Schemas != nil { - return utils.MarshalJSON(u.Schemas, "", true) - } - - if u.ExtensionHookCostDataRetrievalSchemas != nil { - return utils.MarshalJSON(u.ExtensionHookCostDataRetrievalSchemas, "", true) - } - - if u.ExtensionHookMeterReadingPlausibilityCheckSchemas != nil { - return utils.MarshalJSON(u.ExtensionHookMeterReadingPlausibilityCheckSchemas, "", true) - } - - return nil, errors.New("could not marshal union type Hooks: all fields are null") -} - -// Name of the extension. -type Name struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (n Name) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(n, "", false) -} - -func (n *Name) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &n, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *Name) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Name) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -// ExtensionDescription - Description of the option. -type ExtensionDescription struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Description of the option in English. - En string `json:"en"` -} - -func (e ExtensionDescription) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionDescription) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionDescription) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ExtensionDescription) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -// ExtensionName - Name of the option. -type ExtensionName struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the option in English. - En string `json:"en"` -} - -func (e ExtensionName) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionName) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionName) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ExtensionName) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -// ExtensionType - Type of the option. -type ExtensionType string - -const ( - ExtensionTypeText ExtensionType = "text" - ExtensionTypeSecret ExtensionType = "secret" -) - -func (e ExtensionType) ToPointer() *ExtensionType { - return &e -} -func (e *ExtensionType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "text": - fallthrough - case "secret": - *e = ExtensionType(v) - return nil - default: - return fmt.Errorf("invalid value for ExtensionType: %v", v) - } -} - -type OptionsObj struct { - // Default value of the option. - Default *string `json:"default,omitempty"` - // Description of the option. - Description *ExtensionDescription `json:"description,omitempty"` - // Identifier of the option. Should not change between updates. - ID string `json:"id"` - // Name of the option. - Name ExtensionName `json:"name"` - // Indicate whether the option is required. - Required *bool `default:"false" json:"required"` - // Type of the option. - Type ExtensionType `json:"type"` -} - -func (o OptionsObj) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(o, "", false) -} - -func (o *OptionsObj) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, []string{"id", "name", "type"}); err != nil { - return err - } - return nil -} - -func (o *OptionsObj) GetDefault() *string { - if o == nil { - return nil - } - return o.Default -} - -func (o *OptionsObj) GetDescription() *ExtensionDescription { - if o == nil { - return nil - } - return o.Description -} - -func (o *OptionsObj) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *OptionsObj) GetName() ExtensionName { - if o == nil { - return ExtensionName{} - } - return o.Name -} - -func (o *OptionsObj) GetRequired() *bool { - if o == nil { - return nil - } - return o.Required -} - -func (o *OptionsObj) GetType() ExtensionType { - if o == nil { - return ExtensionType("") - } - return o.Type -} - -type Extension struct { - // Identifier of the app from which the extension was installed. Should not change between updates. - AppID *string `json:"app_id,omitempty"` - // Name of the extension. - Description *Description `json:"description,omitempty"` - // Hooks that influence the behavior of Portal. - Hooks []Hooks `json:"hooks,omitempty"` - // Identifier of the extension. Should not change between updates. - ID string `json:"id"` - // External links added to the portal. - Links []ExtensionSeamlessLink `json:"links,omitempty"` - // Name of the extension. - Name Name `json:"name"` - // Options available to the extension configurable by the portal administrator. - Options []OptionsObj `json:"options,omitempty"` - // Version of the extension. - Version *string `json:"version,omitempty"` -} - -func (o *Extension) GetAppID() *string { - if o == nil { - return nil - } - return o.AppID -} - -func (o *Extension) GetDescription() *Description { - if o == nil { - return nil - } - return o.Description -} - -func (o *Extension) GetHooks() []Hooks { - if o == nil { - return nil - } - return o.Hooks -} - -func (o *Extension) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Extension) GetLinks() []ExtensionSeamlessLink { - if o == nil { - return nil - } - return o.Links -} - -func (o *Extension) GetName() Name { - if o == nil { - return Name{} - } - return o.Name -} - -func (o *Extension) GetOptions() []OptionsObj { - if o == nil { - return nil - } - return o.Options -} - -func (o *Extension) GetVersion() *string { - if o == nil { - return nil - } - return o.Version -} diff --git a/internal/sdk/models/shared/extensionauthblock.go b/internal/sdk/models/shared/extensionauthblock.go deleted file mode 100644 index 887e345..0000000 --- a/internal/sdk/models/shared/extensionauthblock.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Cache struct { - // Key to use to identify the auth response. Supports interpolation. - Key string `json:"key"` - // Time to live in seconds for the cache. Supports interpolation. - TTL string `json:"ttl"` -} - -func (o *Cache) GetKey() string { - if o == nil { - return "" - } - return o.Key -} - -func (o *Cache) GetTTL() string { - if o == nil { - return "" - } - return o.TTL -} - -type ExtensionAuthBlock struct { - // JSON body to use for authentication. Supports variable interpolation. Content format is determined by Content-Type header. - Body map[string]string `json:"body,omitempty"` - Cache *Cache `json:"cache,omitempty"` - // Headers to use for authentication. Supports variable interpolation. - Headers map[string]string `json:"headers,omitempty"` - // HTTP method to use for authentication - Method *string `default:"GET" json:"method"` - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to use for authentication. Supports variable interpolation. - URL string `json:"url"` -} - -func (e ExtensionAuthBlock) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionAuthBlock) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"url"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionAuthBlock) GetBody() map[string]string { - if o == nil { - return nil - } - return o.Body -} - -func (o *ExtensionAuthBlock) GetCache() *Cache { - if o == nil { - return nil - } - return o.Cache -} - -func (o *ExtensionAuthBlock) GetHeaders() map[string]string { - if o == nil { - return nil - } - return o.Headers -} - -func (o *ExtensionAuthBlock) GetMethod() *string { - if o == nil { - return nil - } - return o.Method -} - -func (o *ExtensionAuthBlock) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *ExtensionAuthBlock) GetURL() string { - if o == nil { - return "" - } - return o.URL -} diff --git a/internal/sdk/models/shared/extensionconfig.go b/internal/sdk/models/shared/extensionconfig.go deleted file mode 100644 index 595608c..0000000 --- a/internal/sdk/models/shared/extensionconfig.go +++ /dev/null @@ -1,77 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// ExtensionConfigStatus - Status of the extension -type ExtensionConfigStatus string - -const ( - ExtensionConfigStatusInstalled ExtensionConfigStatus = "installed" - ExtensionConfigStatusEnabled ExtensionConfigStatus = "enabled" -) - -func (e ExtensionConfigStatus) ToPointer() *ExtensionConfigStatus { - return &e -} -func (e *ExtensionConfigStatus) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "installed": - fallthrough - case "enabled": - *e = ExtensionConfigStatus(v) - return nil - default: - return fmt.Errorf("invalid value for ExtensionConfigStatus: %v", v) - } -} - -type ExtensionConfig struct { - // Name of the extension - ID string `json:"id"` - // Extension option values. - Options map[string]string `json:"options,omitempty"` - // Status of the extension - Status *ExtensionConfigStatus `default:"installed" json:"status"` -} - -func (e ExtensionConfig) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionConfig) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"id"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionConfig) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ExtensionConfig) GetOptions() map[string]string { - if o == nil { - return nil - } - return o.Options -} - -func (o *ExtensionConfig) GetStatus() *ExtensionConfigStatus { - if o == nil { - return nil - } - return o.Status -} diff --git a/internal/sdk/models/shared/extensionhookconfig.go b/internal/sdk/models/shared/extensionhookconfig.go deleted file mode 100644 index 39ef3ab..0000000 --- a/internal/sdk/models/shared/extensionhookconfig.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ExtensionHookConfig struct { - // The ID of the app that is being hooked into. - AppID *string `json:"app_id,omitempty"` - // The ID of the hook that is being configured. - HookID *string `json:"hook_id,omitempty"` -} - -func (o *ExtensionHookConfig) GetAppID() *string { - if o == nil { - return nil - } - return o.AppID -} - -func (o *ExtensionHookConfig) GetHookID() *string { - if o == nil { - return nil - } - return o.HookID -} diff --git a/internal/sdk/models/shared/extensionseamlesslink.go b/internal/sdk/models/shared/extensionseamlesslink.go deleted file mode 100644 index daaf9c7..0000000 --- a/internal/sdk/models/shared/extensionseamlesslink.go +++ /dev/null @@ -1,180 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// ExtensionSeamlessLinkDescription - Name of the extension. -type ExtensionSeamlessLinkDescription struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (e ExtensionSeamlessLinkDescription) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionSeamlessLinkDescription) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionSeamlessLinkDescription) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ExtensionSeamlessLinkDescription) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -// ExtensionSeamlessLinkName - Name of the extension. -type ExtensionSeamlessLinkName struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (e ExtensionSeamlessLinkName) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(e, "", false) -} - -func (e *ExtensionSeamlessLinkName) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &e, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *ExtensionSeamlessLinkName) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *ExtensionSeamlessLinkName) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type Redirect struct { - // Parameters to append to the URL. Supports variable interpolation. - Params map[string]string `json:"params,omitempty"` - // URL to redirect to. Supports variable interpolation. - URL *string `json:"url,omitempty"` -} - -func (o *Redirect) GetParams() map[string]string { - if o == nil { - return nil - } - return o.Params -} - -func (o *Redirect) GetURL() *string { - if o == nil { - return nil - } - return o.URL -} - -type ExtensionSeamlessLinkType string - -const ( - ExtensionSeamlessLinkTypeSeamless ExtensionSeamlessLinkType = "seamless" -) - -func (e ExtensionSeamlessLinkType) ToPointer() *ExtensionSeamlessLinkType { - return &e -} -func (e *ExtensionSeamlessLinkType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "seamless": - *e = ExtensionSeamlessLinkType(v) - return nil - default: - return fmt.Errorf("invalid value for ExtensionSeamlessLinkType: %v", v) - } -} - -type ExtensionSeamlessLink struct { - Auth *ExtensionAuthBlock `json:"auth,omitempty"` - // Controls whether the link should be shown. Supports variable interpolation. - Condition *string `json:"condition,omitempty"` - // Name of the extension. - Description *ExtensionSeamlessLinkDescription `json:"description,omitempty"` - // Identifier of the link. Should not change between updates. - ID string `json:"id"` - // Name of the extension. - Name ExtensionSeamlessLinkName `json:"name"` - Redirect Redirect `json:"redirect"` - Type ExtensionSeamlessLinkType `json:"type"` -} - -func (o *ExtensionSeamlessLink) GetAuth() *ExtensionAuthBlock { - if o == nil { - return nil - } - return o.Auth -} - -func (o *ExtensionSeamlessLink) GetCondition() *string { - if o == nil { - return nil - } - return o.Condition -} - -func (o *ExtensionSeamlessLink) GetDescription() *ExtensionSeamlessLinkDescription { - if o == nil { - return nil - } - return o.Description -} - -func (o *ExtensionSeamlessLink) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ExtensionSeamlessLink) GetName() ExtensionSeamlessLinkName { - if o == nil { - return ExtensionSeamlessLinkName{} - } - return o.Name -} - -func (o *ExtensionSeamlessLink) GetRedirect() Redirect { - if o == nil { - return Redirect{} - } - return o.Redirect -} - -func (o *ExtensionSeamlessLink) GetType() ExtensionSeamlessLinkType { - if o == nil { - return ExtensionSeamlessLinkType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/externallink.go b/internal/sdk/models/shared/externallink.go deleted file mode 100644 index 48bbf09..0000000 --- a/internal/sdk/models/shared/externallink.go +++ /dev/null @@ -1,161 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -// Icon - Configuration of the icon for the external link -type Icon struct { - // The color of the icon - Color *string `json:"color,omitempty"` - // The name of the icon - Name *string `json:"name,omitempty"` - // Size of the icon in pixels - Size *int64 `json:"size,omitempty"` -} - -func (o *Icon) GetColor() *string { - if o == nil { - return nil - } - return o.Color -} - -func (o *Icon) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *Icon) GetSize() *int64 { - if o == nil { - return nil - } - return o.Size -} - -type Rules struct { -} - -type ExternalLinkType string - -const ( - ExternalLinkTypeLink ExternalLinkType = "link" - ExternalLinkTypeJourney ExternalLinkType = "journey" - ExternalLinkTypeSeamless ExternalLinkType = "seamless" -) - -func (e ExternalLinkType) ToPointer() *ExternalLinkType { - return &e -} -func (e *ExternalLinkType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "link": - fallthrough - case "journey": - fallthrough - case "seamless": - *e = ExternalLinkType(v) - return nil - default: - return fmt.Errorf("invalid value for ExternalLinkType: %v", v) - } -} - -type ExternalLink struct { - // Attribute associated with the link - Attribute *string `json:"attribute,omitempty"` - // Attribute value for the link - AttributeValue *string `json:"attribute_value,omitempty"` - // Entity associated with the link - Entity *string `json:"entity,omitempty"` - // Seamless link identifier in a form of [extensionId, linkId] - ExtensionLinkID []string `json:"extension_link_id,omitempty"` - // Configuration of the icon for the external link - Icon *Icon `json:"icon,omitempty"` - // Unique identifier for the external link - ID string `json:"id"` - Label map[string]string `json:"label"` - // The URL of the external link - Link string `json:"link"` - Rules []Rules `json:"rules,omitempty"` - Type ExternalLinkType `json:"type"` -} - -func (o *ExternalLink) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *ExternalLink) GetAttributeValue() *string { - if o == nil { - return nil - } - return o.AttributeValue -} - -func (o *ExternalLink) GetEntity() *string { - if o == nil { - return nil - } - return o.Entity -} - -func (o *ExternalLink) GetExtensionLinkID() []string { - if o == nil { - return nil - } - return o.ExtensionLinkID -} - -func (o *ExternalLink) GetIcon() *Icon { - if o == nil { - return nil - } - return o.Icon -} - -func (o *ExternalLink) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *ExternalLink) GetLabel() map[string]string { - if o == nil { - return map[string]string{} - } - return o.Label -} - -func (o *ExternalLink) GetLink() string { - if o == nil { - return "" - } - return o.Link -} - -func (o *ExternalLink) GetRules() []Rules { - if o == nil { - return nil - } - return o.Rules -} - -func (o *ExternalLink) GetType() ExternalLinkType { - if o == nil { - return ExternalLinkType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/extraschemaattributes.go b/internal/sdk/models/shared/extraschemaattributes.go deleted file mode 100644 index f2222e9..0000000 --- a/internal/sdk/models/shared/extraschemaattributes.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ExtraSchemaAttributes struct { - // Attribute group - Group string `json:"group"` - // Attribute label - Label string `json:"label"` - // Attribute name - Name string `json:"name"` -} - -func (o *ExtraSchemaAttributes) GetGroup() string { - if o == nil { - return "" - } - return o.Group -} - -func (o *ExtraSchemaAttributes) GetLabel() string { - if o == nil { - return "" - } - return o.Label -} - -func (o *ExtraSchemaAttributes) GetName() string { - if o == nil { - return "" - } - return o.Name -} diff --git a/internal/sdk/models/shared/failedruleerrorresp.go b/internal/sdk/models/shared/failedruleerrorresp.go deleted file mode 100644 index 245eac0..0000000 --- a/internal/sdk/models/shared/failedruleerrorresp.go +++ /dev/null @@ -1,54 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// FailedRule - Failed validation rule -type FailedRule struct { -} - -func (f FailedRule) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(f, "", false) -} - -func (f *FailedRule) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &f, "", false, nil); err != nil { - return err - } - return nil -} - -type FailedRuleErrorResp struct { - // Failed validation rule - FailedRule *FailedRule `json:"failed_rule,omitempty"` - // Error message - Message *string `json:"message,omitempty"` -} - -func (f FailedRuleErrorResp) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(f, "", false) -} - -func (f *FailedRuleErrorResp) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &f, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *FailedRuleErrorResp) GetFailedRule() *FailedRule { - if o == nil { - return nil - } - return o.FailedRule -} - -func (o *FailedRuleErrorResp) GetMessage() *string { - if o == nil { - return nil - } - return o.Message -} diff --git a/internal/sdk/models/shared/file.go b/internal/sdk/models/shared/file.go deleted file mode 100644 index 55d85bb..0000000 --- a/internal/sdk/models/shared/file.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type FileSchema string - -const ( - FileSchemaFile FileSchema = "file" -) - -func (e FileSchema) ToPointer() *FileSchema { - return &e -} -func (e *FileSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "file": - *e = FileSchema(v) - return nil - default: - return fmt.Errorf("invalid value for FileSchema: %v", v) - } -} - -// File - The file entity -type File struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema FileSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (f File) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(f, "", false) -} - -func (f *File) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &f, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *File) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *File) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *File) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *File) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *File) GetSchema() FileSchema { - if o == nil { - return FileSchema("") - } - return o.Schema -} - -func (o *File) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *File) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *File) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/fileitem.go b/internal/sdk/models/shared/fileitem.go deleted file mode 100644 index ed220f3..0000000 --- a/internal/sdk/models/shared/fileitem.go +++ /dev/null @@ -1,300 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type Relations struct { - // URL-friendly identifier for the entity schema - Schema *EntitySlug `json:"_schema,omitempty"` - // The title of the parent entity - Title *string `json:"_title,omitempty"` - // Entity ID - EntityID *string `json:"entity_id,omitempty"` -} - -func (o *Relations) GetSchema() *EntitySlug { - if o == nil { - return nil - } - return o.Schema -} - -func (o *Relations) GetTitle() *string { - if o == nil { - return nil - } - return o.Title -} - -func (o *Relations) GetEntityID() *string { - if o == nil { - return nil - } - return o.EntityID -} - -type FileItemSchema string - -const ( - FileItemSchemaFile FileItemSchema = "file" -) - -func (e FileItemSchema) ToPointer() *FileItemSchema { - return &e -} -func (e *FileItemSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "file": - *e = FileItemSchema(v) - return nil - default: - return fmt.Errorf("invalid value for FileItemSchema: %v", v) - } -} - -type AccessControl string - -const ( - AccessControlPrivate AccessControl = "private" - AccessControlPublicRead AccessControl = "public-read" -) - -func (e AccessControl) ToPointer() *AccessControl { - return &e -} -func (e *AccessControl) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "private": - fallthrough - case "public-read": - *e = AccessControl(v) - return nil - default: - return fmt.Errorf("invalid value for AccessControl: %v", v) - } -} - -// FileItemType - Human readable type for file -type FileItemType string - -const ( - FileItemTypeDocument FileItemType = "document" - FileItemTypeDocumentTemplate FileItemType = "document_template" - FileItemTypeText FileItemType = "text" - FileItemTypeImage FileItemType = "image" - FileItemTypeVideo FileItemType = "video" - FileItemTypeAudio FileItemType = "audio" - FileItemTypeSpreadsheet FileItemType = "spreadsheet" - FileItemTypePresentation FileItemType = "presentation" - FileItemTypeFont FileItemType = "font" - FileItemTypeArchive FileItemType = "archive" - FileItemTypeApplication FileItemType = "application" - FileItemTypeUnknown FileItemType = "unknown" -) - -func (e FileItemType) ToPointer() *FileItemType { - return &e -} -func (e *FileItemType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "document": - fallthrough - case "document_template": - fallthrough - case "text": - fallthrough - case "image": - fallthrough - case "video": - fallthrough - case "audio": - fallthrough - case "spreadsheet": - fallthrough - case "presentation": - fallthrough - case "font": - fallthrough - case "archive": - fallthrough - case "application": - fallthrough - case "unknown": - *e = FileItemType(v) - return nil - default: - return fmt.Errorf("invalid value for FileItemType: %v", v) - } -} - -// FileItem - The file entity -type FileItem struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Relations []Relations `json:"_relations,omitempty"` - Schema FileItemSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` - AccessControl *AccessControl `default:"private" json:"access_control"` - // The date used for sorting the file - FileDate *time.Time `json:"file_date,omitempty"` - Filename *string `json:"filename,omitempty"` - // Indicate whether the user has not seen/downloaded the file before - IsNew *bool `json:"is_new,omitempty"` - // MIME type of the file - MimeType *string `json:"mime_type,omitempty"` - // Direct URL for file (public only if file access control is public-read) - PublicURL *string `json:"public_url,omitempty"` - // Human readable type for file - Type *FileItemType `json:"type,omitempty"` -} - -func (f FileItem) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(f, "", false) -} - -func (f *FileItem) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &f, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *FileItem) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *FileItem) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *FileItem) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *FileItem) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *FileItem) GetRelations() []Relations { - if o == nil { - return nil - } - return o.Relations -} - -func (o *FileItem) GetSchema() FileItemSchema { - if o == nil { - return FileItemSchema("") - } - return o.Schema -} - -func (o *FileItem) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *FileItem) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *FileItem) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} - -func (o *FileItem) GetAccessControl() *AccessControl { - if o == nil { - return nil - } - return o.AccessControl -} - -func (o *FileItem) GetFileDate() *time.Time { - if o == nil { - return nil - } - return o.FileDate -} - -func (o *FileItem) GetFilename() *string { - if o == nil { - return nil - } - return o.Filename -} - -func (o *FileItem) GetIsNew() *bool { - if o == nil { - return nil - } - return o.IsNew -} - -func (o *FileItem) GetMimeType() *string { - if o == nil { - return nil - } - return o.MimeType -} - -func (o *FileItem) GetPublicURL() *string { - if o == nil { - return nil - } - return o.PublicURL -} - -func (o *FileItem) GetType() *FileItemType { - if o == nil { - return nil - } - return o.Type -} diff --git a/internal/sdk/models/shared/grant.go b/internal/sdk/models/shared/grant.go index 7137052..cc35d1c 100644 --- a/internal/sdk/models/shared/grant.go +++ b/internal/sdk/models/shared/grant.go @@ -8,7 +8,6 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" ) -// Effect of the permission type Effect string const ( @@ -36,12 +35,10 @@ func (e *Effect) UnmarshalJSON(data []byte) error { } type Grant struct { - // Action for granting permission - Action string `json:"action"` - // Effect of the permission - Effect *Effect `default:"allow" json:"effect"` - // Resource for granting permission - Resource *string `json:"resource,omitempty"` + Action string `json:"action"` + Conditions []GrantCondition `json:"conditions,omitempty"` + Effect *Effect `default:"allow" json:"effect"` + Resource *string `json:"resource,omitempty"` } func (g Grant) MarshalJSON() ([]byte, error) { @@ -55,23 +52,30 @@ func (g *Grant) UnmarshalJSON(data []byte) error { return nil } -func (o *Grant) GetAction() string { - if o == nil { +func (g *Grant) GetAction() string { + if g == nil { return "" } - return o.Action + return g.Action } -func (o *Grant) GetEffect() *Effect { - if o == nil { +func (g *Grant) GetConditions() []GrantCondition { + if g == nil { return nil } - return o.Effect + return g.Conditions } -func (o *Grant) GetResource() *string { - if o == nil { +func (g *Grant) GetEffect() *Effect { + if g == nil { return nil } - return o.Resource + return g.Effect +} + +func (g *Grant) GetResource() *string { + if g == nil { + return nil + } + return g.Resource } diff --git a/internal/sdk/models/shared/grantcondition.go b/internal/sdk/models/shared/grantcondition.go new file mode 100644 index 0000000..3924244 --- /dev/null +++ b/internal/sdk/models/shared/grantcondition.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" +) + +type GrantConditionType string + +const ( + GrantConditionTypeEqualsCondition GrantConditionType = "EqualsCondition" +) + +// GrantCondition - An additional condition that must be met for the grant +type GrantCondition struct { + EqualsCondition *EqualsCondition `queryParam:"inline,name=GrantCondition"` + + Type GrantConditionType +} + +func CreateGrantConditionEqualsCondition(equalsCondition EqualsCondition) GrantCondition { + typ := GrantConditionTypeEqualsCondition + + return GrantCondition{ + EqualsCondition: &equalsCondition, + Type: typ, + } +} + +func (u *GrantCondition) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var equalsCondition EqualsCondition = EqualsCondition{} + if err := utils.UnmarshalJSON(data, &equalsCondition, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: GrantConditionTypeEqualsCondition, + Value: &equalsCondition, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GrantCondition", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GrantCondition", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(GrantConditionType) + switch best.Type { + case GrantConditionTypeEqualsCondition: + u.EqualsCondition = best.Value.(*EqualsCondition) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for GrantCondition", string(data)) +} + +func (u GrantCondition) MarshalJSON() ([]byte, error) { + if u.EqualsCondition != nil { + return utils.MarshalJSON(u.EqualsCondition, "", true) + } + + return nil, errors.New("could not marshal union type GrantCondition: all fields are null") +} diff --git a/internal/sdk/models/shared/grantwithdependencies.go b/internal/sdk/models/shared/grantwithdependencies.go new file mode 100644 index 0000000..12eb4a7 --- /dev/null +++ b/internal/sdk/models/shared/grantwithdependencies.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" +) + +type GrantWithDependenciesEffect string + +const ( + GrantWithDependenciesEffectAllow GrantWithDependenciesEffect = "allow" + GrantWithDependenciesEffectDeny GrantWithDependenciesEffect = "deny" +) + +func (e GrantWithDependenciesEffect) ToPointer() *GrantWithDependenciesEffect { + return &e +} +func (e *GrantWithDependenciesEffect) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "allow": + fallthrough + case "deny": + *e = GrantWithDependenciesEffect(v) + return nil + default: + return fmt.Errorf("invalid value for GrantWithDependenciesEffect: %v", v) + } +} + +type GrantWithDependencies struct { + Action string `json:"action"` + Conditions []GrantCondition `json:"conditions,omitempty"` + // Provided additional dependencies, exploded when storing the role + Dependencies []Grant `json:"dependencies,omitempty"` + Effect *GrantWithDependenciesEffect `default:"allow" json:"effect"` + Resource *string `json:"resource,omitempty"` +} + +func (g GrantWithDependencies) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GrantWithDependencies) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"action"}); err != nil { + return err + } + return nil +} + +func (g *GrantWithDependencies) GetAction() string { + if g == nil { + return "" + } + return g.Action +} + +func (g *GrantWithDependencies) GetConditions() []GrantCondition { + if g == nil { + return nil + } + return g.Conditions +} + +func (g *GrantWithDependencies) GetDependencies() []Grant { + if g == nil { + return nil + } + return g.Dependencies +} + +func (g *GrantWithDependencies) GetEffect() *GrantWithDependenciesEffect { + if g == nil { + return nil + } + return g.Effect +} + +func (g *GrantWithDependencies) GetResource() *string { + if g == nil { + return nil + } + return g.Resource +} diff --git a/internal/sdk/models/shared/identifierattribute.go b/internal/sdk/models/shared/identifierattribute.go deleted file mode 100644 index 19b4734..0000000 --- a/internal/sdk/models/shared/identifierattribute.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type IdentifierAttribute struct { - // Label attribute - Label *string `json:"label,omitempty"` - // Name of the attribute - Name *string `json:"name,omitempty"` - // Type of the secondary attribute - Type *string `json:"type,omitempty"` -} - -func (o *IdentifierAttribute) GetLabel() *string { - if o == nil { - return nil - } - return o.Label -} - -func (o *IdentifierAttribute) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *IdentifierAttribute) GetType() *string { - if o == nil { - return nil - } - return o.Type -} diff --git a/internal/sdk/models/shared/journeyactions.go b/internal/sdk/models/shared/journeyactions.go deleted file mode 100644 index f95531b..0000000 --- a/internal/sdk/models/shared/journeyactions.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type JourneyActions struct { - ActionLabel *ActionLabel `json:"action_label,omitempty"` - JourneyID *string `json:"journey_id,omitempty"` - Rules []Rule `json:"rules,omitempty"` - Slug *string `json:"slug,omitempty"` -} - -func (j JourneyActions) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(j, "", false) -} - -func (j *JourneyActions) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &j, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *JourneyActions) GetActionLabel() *ActionLabel { - if o == nil { - return nil - } - return o.ActionLabel -} - -func (o *JourneyActions) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *JourneyActions) GetRules() []Rule { - if o == nil { - return nil - } - return o.Rules -} - -func (o *JourneyActions) GetSlug() *string { - if o == nil { - return nil - } - return o.Slug -} diff --git a/internal/sdk/models/shared/juicesettings.go b/internal/sdk/models/shared/juicesettings.go deleted file mode 100644 index 94b457a..0000000 --- a/internal/sdk/models/shared/juicesettings.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type JuiceSettings struct { - // Whether the org is in canary mode - IsCanary *bool `json:"is_canary,omitempty"` - // Whether the org is in dummy mode - IsDummy *bool `json:"is_dummy,omitempty"` -} - -func (o *JuiceSettings) GetIsCanary() *bool { - if o == nil { - return nil - } - return o.IsCanary -} - -func (o *JuiceSettings) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} diff --git a/internal/sdk/models/shared/meter.go b/internal/sdk/models/shared/meter.go deleted file mode 100644 index b8ee114..0000000 --- a/internal/sdk/models/shared/meter.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type MeterSchema string - -const ( - MeterSchemaMeter MeterSchema = "meter" -) - -func (e MeterSchema) ToPointer() *MeterSchema { - return &e -} -func (e *MeterSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "meter": - *e = MeterSchema(v) - return nil - default: - return fmt.Errorf("invalid value for MeterSchema: %v", v) - } -} - -// Meter - The meter entity -type Meter struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema MeterSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (m Meter) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *Meter) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Meter) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Meter) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Meter) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Meter) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Meter) GetSchema() MeterSchema { - if o == nil { - return MeterSchema("") - } - return o.Schema -} - -func (o *Meter) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Meter) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Meter) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/meterchartwidget.go b/internal/sdk/models/shared/meterchartwidget.go deleted file mode 100644 index 4c263ca..0000000 --- a/internal/sdk/models/shared/meterchartwidget.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type MeterChartWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (m MeterChartWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterChartWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *MeterChartWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *MeterChartWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type MeterChartWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (m MeterChartWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterChartWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *MeterChartWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *MeterChartWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type MeterChartWidgetType string - -const ( - MeterChartWidgetTypeActionWidget MeterChartWidgetType = "ACTION_WIDGET" - MeterChartWidgetTypeContentWidget MeterChartWidgetType = "CONTENT_WIDGET" - MeterChartWidgetTypeEntityWidget MeterChartWidgetType = "ENTITY_WIDGET" - MeterChartWidgetTypeTeaserWidget MeterChartWidgetType = "TEASER_WIDGET" - MeterChartWidgetTypeDocumentWidget MeterChartWidgetType = "DOCUMENT_WIDGET" - MeterChartWidgetTypePaymentWidget MeterChartWidgetType = "PAYMENT_WIDGET" - MeterChartWidgetTypeMeterReadingWidget MeterChartWidgetType = "METER_READING_WIDGET" - MeterChartWidgetTypeMeterChartWidget MeterChartWidgetType = "METER_CHART_WIDGET" - MeterChartWidgetTypeCampaignWidget MeterChartWidgetType = "CAMPAIGN_WIDGET" -) - -func (e MeterChartWidgetType) ToPointer() *MeterChartWidgetType { - return &e -} -func (e *MeterChartWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = MeterChartWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for MeterChartWidgetType: %v", v) - } -} - -type MeterChartWidget struct { - Headline *MeterChartWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - Schema *string `json:"schema,omitempty"` - SubHeadline *MeterChartWidgetSubHeadline `json:"subHeadline,omitempty"` - Type MeterChartWidgetType `json:"type"` -} - -func (m MeterChartWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterChartWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *MeterChartWidget) GetHeadline() *MeterChartWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *MeterChartWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *MeterChartWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *MeterChartWidget) GetSchema() *string { - if o == nil { - return nil - } - return o.Schema -} - -func (o *MeterChartWidget) GetSubHeadline() *MeterChartWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *MeterChartWidget) GetType() MeterChartWidgetType { - if o == nil { - return MeterChartWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/meterreadingphoto.go b/internal/sdk/models/shared/meterreadingphoto.go deleted file mode 100644 index 6a249a2..0000000 --- a/internal/sdk/models/shared/meterreadingphoto.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type MeterReadingPhoto struct { - // Base64 encoded image - Contents string `json:"contents"` - Filename string `json:"filename"` - // Entity ID - MeterID string `json:"meter_id"` - MimeType string `json:"mime_type"` -} - -func (o *MeterReadingPhoto) GetContents() string { - if o == nil { - return "" - } - return o.Contents -} - -func (o *MeterReadingPhoto) GetFilename() string { - if o == nil { - return "" - } - return o.Filename -} - -func (o *MeterReadingPhoto) GetMeterID() string { - if o == nil { - return "" - } - return o.MeterID -} - -func (o *MeterReadingPhoto) GetMimeType() string { - if o == nil { - return "" - } - return o.MimeType -} diff --git a/internal/sdk/models/shared/meterreadingphotodata.go b/internal/sdk/models/shared/meterreadingphotodata.go deleted file mode 100644 index d944aad..0000000 --- a/internal/sdk/models/shared/meterreadingphotodata.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type S3ref struct { - // S3 bucket name - Bucket string `json:"bucket"` - // S3 key - Key string `json:"key"` -} - -func (o *S3ref) GetBucket() string { - if o == nil { - return "" - } - return o.Bucket -} - -func (o *S3ref) GetKey() string { - if o == nil { - return "" - } - return o.Key -} - -type MeterReadingPhotoData struct { - Filename string `json:"filename"` - // Recognized list of (potential) meter numbers. - MeterNumbers []string `json:"meter_numbers,omitempty"` - // Recognized meter reading. - Reading *string `json:"reading,omitempty"` - S3ref S3ref `json:"s3ref"` - // Recognized sector of the meter. - Sector *string `json:"sector,omitempty"` -} - -func (o *MeterReadingPhotoData) GetFilename() string { - if o == nil { - return "" - } - return o.Filename -} - -func (o *MeterReadingPhotoData) GetMeterNumbers() []string { - if o == nil { - return nil - } - return o.MeterNumbers -} - -func (o *MeterReadingPhotoData) GetReading() *string { - if o == nil { - return nil - } - return o.Reading -} - -func (o *MeterReadingPhotoData) GetS3ref() S3ref { - if o == nil { - return S3ref{} - } - return o.S3ref -} - -func (o *MeterReadingPhotoData) GetSector() *string { - if o == nil { - return nil - } - return o.Sector -} diff --git a/internal/sdk/models/shared/meterreadingwidget.go b/internal/sdk/models/shared/meterreadingwidget.go deleted file mode 100644 index 2c66062..0000000 --- a/internal/sdk/models/shared/meterreadingwidget.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type MeterReadingWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (m MeterReadingWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterReadingWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *MeterReadingWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *MeterReadingWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type MeterReadingWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (m MeterReadingWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterReadingWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *MeterReadingWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *MeterReadingWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type MeterReadingWidgetType string - -const ( - MeterReadingWidgetTypeActionWidget MeterReadingWidgetType = "ACTION_WIDGET" - MeterReadingWidgetTypeContentWidget MeterReadingWidgetType = "CONTENT_WIDGET" - MeterReadingWidgetTypeEntityWidget MeterReadingWidgetType = "ENTITY_WIDGET" - MeterReadingWidgetTypeTeaserWidget MeterReadingWidgetType = "TEASER_WIDGET" - MeterReadingWidgetTypeDocumentWidget MeterReadingWidgetType = "DOCUMENT_WIDGET" - MeterReadingWidgetTypePaymentWidget MeterReadingWidgetType = "PAYMENT_WIDGET" - MeterReadingWidgetTypeMeterReadingWidget MeterReadingWidgetType = "METER_READING_WIDGET" - MeterReadingWidgetTypeMeterChartWidget MeterReadingWidgetType = "METER_CHART_WIDGET" - MeterReadingWidgetTypeCampaignWidget MeterReadingWidgetType = "CAMPAIGN_WIDGET" -) - -func (e MeterReadingWidgetType) ToPointer() *MeterReadingWidgetType { - return &e -} -func (e *MeterReadingWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = MeterReadingWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for MeterReadingWidgetType: %v", v) - } -} - -type MeterReadingWidget struct { - Headline *MeterReadingWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - Schema *string `json:"schema,omitempty"` - SubHeadline *MeterReadingWidgetSubHeadline `json:"subHeadline,omitempty"` - Type MeterReadingWidgetType `json:"type"` -} - -func (m MeterReadingWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(m, "", false) -} - -func (m *MeterReadingWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &m, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *MeterReadingWidget) GetHeadline() *MeterReadingWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *MeterReadingWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *MeterReadingWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *MeterReadingWidget) GetSchema() *string { - if o == nil { - return nil - } - return o.Schema -} - -func (o *MeterReadingWidget) GetSubHeadline() *MeterReadingWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *MeterReadingWidget) GetType() MeterReadingWidgetType { - if o == nil { - return MeterReadingWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/moblieoidcconfig.go b/internal/sdk/models/shared/moblieoidcconfig.go deleted file mode 100644 index a2d8d60..0000000 --- a/internal/sdk/models/shared/moblieoidcconfig.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type MoblieOIDCConfig struct { - // Client ID for the mobile app - ClientID *string `json:"client_id,omitempty"` - // Client Secret for the mobile app - ClientSecret *string `json:"client_secret,omitempty"` -} - -func (o *MoblieOIDCConfig) GetClientID() *string { - if o == nil { - return nil - } - return o.ClientID -} - -func (o *MoblieOIDCConfig) GetClientSecret() *string { - if o == nil { - return nil - } - return o.ClientSecret -} diff --git a/internal/sdk/models/shared/oidcproviderconfig.go b/internal/sdk/models/shared/oidcproviderconfig.go deleted file mode 100644 index dfbc1f0..0000000 --- a/internal/sdk/models/shared/oidcproviderconfig.go +++ /dev/null @@ -1,154 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Prompt string - -const ( - PromptLogin Prompt = "login" - PromptSelectAccount Prompt = "select_account" - PromptConsent Prompt = "consent" -) - -func (e Prompt) ToPointer() *Prompt { - return &e -} -func (e *Prompt) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "login": - fallthrough - case "select_account": - fallthrough - case "consent": - *e = Prompt(v) - return nil - default: - return fmt.Errorf("invalid value for Prompt: %v", v) - } -} - -type OIDCProviderConfigType string - -const ( - OIDCProviderConfigTypeAuthorizationCode OIDCProviderConfigType = "authorization_code" - OIDCProviderConfigTypeImplicit OIDCProviderConfigType = "implicit" -) - -func (e OIDCProviderConfigType) ToPointer() *OIDCProviderConfigType { - return &e -} -func (e *OIDCProviderConfigType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "authorization_code": - fallthrough - case "implicit": - *e = OIDCProviderConfigType(v) - return nil - default: - return fmt.Errorf("invalid value for OIDCProviderConfigType: %v", v) - } -} - -type OIDCProviderConfig struct { - ClientID string `json:"client_id"` - ClientSecret *string `json:"client_secret,omitempty"` - // Whether the client secret is present - HasClientSecret *bool `json:"has_client_secret,omitempty"` - Metadata *OIDCProviderMetadata `json:"metadata,omitempty"` - // Issuing Authority URL - OidcIssuer string `json:"oidc_issuer"` - Prompt *Prompt `json:"prompt,omitempty"` - // Redirect URI for the OIDC flow - RedirectURI *string `json:"redirect_uri,omitempty"` - // Space-separated list of OAuth 2.0 scopes to request from OpenID Connect - Scope string `json:"scope"` - Type *OIDCProviderConfigType `default:"implicit" json:"type"` -} - -func (o OIDCProviderConfig) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(o, "", false) -} - -func (o *OIDCProviderConfig) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, []string{"client_id", "oidc_issuer", "scope"}); err != nil { - return err - } - return nil -} - -func (o *OIDCProviderConfig) GetClientID() string { - if o == nil { - return "" - } - return o.ClientID -} - -func (o *OIDCProviderConfig) GetClientSecret() *string { - if o == nil { - return nil - } - return o.ClientSecret -} - -func (o *OIDCProviderConfig) GetHasClientSecret() *bool { - if o == nil { - return nil - } - return o.HasClientSecret -} - -func (o *OIDCProviderConfig) GetMetadata() *OIDCProviderMetadata { - if o == nil { - return nil - } - return o.Metadata -} - -func (o *OIDCProviderConfig) GetOidcIssuer() string { - if o == nil { - return "" - } - return o.OidcIssuer -} - -func (o *OIDCProviderConfig) GetPrompt() *Prompt { - if o == nil { - return nil - } - return o.Prompt -} - -func (o *OIDCProviderConfig) GetRedirectURI() *string { - if o == nil { - return nil - } - return o.RedirectURI -} - -func (o *OIDCProviderConfig) GetScope() string { - if o == nil { - return "" - } - return o.Scope -} - -func (o *OIDCProviderConfig) GetType() *OIDCProviderConfigType { - if o == nil { - return nil - } - return o.Type -} diff --git a/internal/sdk/models/shared/oidcprovidermetadata.go b/internal/sdk/models/shared/oidcprovidermetadata.go deleted file mode 100644 index bcac829..0000000 --- a/internal/sdk/models/shared/oidcprovidermetadata.go +++ /dev/null @@ -1,60 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type OIDCProviderMetadata struct { - // URL of the authorization endpoint - AuthorizationEndpoint *string `json:"authorization_endpoint,omitempty"` - // URL of the mobile redirect URI - MobileRedirectURI *string `json:"mobile_redirect_uri,omitempty"` - // The password for the test auth, only used for testing on auth code flow - TestAuthPassword *string `json:"test_auth_password,omitempty"` - // The username for the test auth, only used for testing on auth code flow - TestAuthUsername *string `json:"test_auth_username,omitempty"` - // URL of the token endpoint - TokenEndpoint *string `json:"token_endpoint,omitempty"` - // URL of the userinfo endpoint - UserinfoEndpoint *string `json:"userinfo_endpoint,omitempty"` -} - -func (o *OIDCProviderMetadata) GetAuthorizationEndpoint() *string { - if o == nil { - return nil - } - return o.AuthorizationEndpoint -} - -func (o *OIDCProviderMetadata) GetMobileRedirectURI() *string { - if o == nil { - return nil - } - return o.MobileRedirectURI -} - -func (o *OIDCProviderMetadata) GetTestAuthPassword() *string { - if o == nil { - return nil - } - return o.TestAuthPassword -} - -func (o *OIDCProviderMetadata) GetTestAuthUsername() *string { - if o == nil { - return nil - } - return o.TestAuthUsername -} - -func (o *OIDCProviderMetadata) GetTokenEndpoint() *string { - if o == nil { - return nil - } - return o.TokenEndpoint -} - -func (o *OIDCProviderMetadata) GetUserinfoEndpoint() *string { - if o == nil { - return nil - } - return o.UserinfoEndpoint -} diff --git a/internal/sdk/models/shared/opportunity.go b/internal/sdk/models/shared/opportunity.go deleted file mode 100644 index c5bac95..0000000 --- a/internal/sdk/models/shared/opportunity.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type OpportunitySchema string - -const ( - OpportunitySchemaOpportunity OpportunitySchema = "opportunity" -) - -func (e OpportunitySchema) ToPointer() *OpportunitySchema { - return &e -} -func (e *OpportunitySchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "opportunity": - *e = OpportunitySchema(v) - return nil - default: - return fmt.Errorf("invalid value for OpportunitySchema: %v", v) - } -} - -// Opportunity - The opportunity entity -type Opportunity struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema OpportunitySchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (o Opportunity) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(o, "", false) -} - -func (o *Opportunity) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Opportunity) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Opportunity) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Opportunity) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Opportunity) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Opportunity) GetSchema() OpportunitySchema { - if o == nil { - return OpportunitySchema("") - } - return o.Schema -} - -func (o *Opportunity) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Opportunity) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Opportunity) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/order.go b/internal/sdk/models/shared/order.go deleted file mode 100644 index f0afa09..0000000 --- a/internal/sdk/models/shared/order.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type OrderSchema string - -const ( - OrderSchemaOrder OrderSchema = "order" -) - -func (e OrderSchema) ToPointer() *OrderSchema { - return &e -} -func (e *OrderSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "order": - *e = OrderSchema(v) - return nil - default: - return fmt.Errorf("invalid value for OrderSchema: %v", v) - } -} - -// Order - The order entity -type Order struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema OrderSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (o Order) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(o, "", false) -} - -func (o *Order) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Order) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Order) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Order) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Order) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Order) GetSchema() OrderSchema { - if o == nil { - return OrderSchema("") - } - return o.Schema -} - -func (o *Order) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Order) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Order) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/organizationsettings.go b/internal/sdk/models/shared/organizationsettings.go deleted file mode 100644 index 33c7865..0000000 --- a/internal/sdk/models/shared/organizationsettings.go +++ /dev/null @@ -1,386 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type AutomationEntityMapping struct { - // Enable/Disable automation entity mapping - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *AutomationEntityMapping) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type AutomationPreview struct { - // Enable/Disable automation preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *AutomationPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type CentralInboxPreviewSetting struct { - // Enable/Disable central inbox preview setting - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *CentralInboxPreviewSetting) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type ContractsPreviewSetting struct { - // Enable/Disable contracts preview setting - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *ContractsPreviewSetting) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type DisableIvy struct { - // Enable/Disable Ivy - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *DisableIvy) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type DoubleOptIn struct { - // Enable/Disable double opt-in - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *DoubleOptIn) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EcommerceCatalogPreview struct { - // Enable/Disable ecommerce catalog preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *EcommerceCatalogPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EcommerceOpportunitiesPreview struct { - // Enable/Disable ecommerce opportunities preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *EcommerceOpportunitiesPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EcommercePreview struct { - // Enable/Disable ecommerce preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *EcommercePreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EndCustomerPortal struct { - // Enable/Disable end customer portal - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *EndCustomerPortal) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EntitySchemaBuilder struct { - // Enable/Disable entity schema builder - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *EntitySchemaBuilder) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type InstallerPortal struct { - // Enable/Disable installer portal - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *InstallerPortal) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type LogicEditorPreview struct { - // Enable/Disable logic editor preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *LogicEditorPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type NewNavigation struct { - // Enable/Disable new navigation - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *NewNavigation) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type Partnering struct { - // Enable/Disable partnering - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Partnering) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type ProductAvailability struct { - // Enable/Disable product availability - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *ProductAvailability) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type Sso struct { - // Enable/Disable single sign-on (SSO) - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Sso) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type SubmissionPreview struct { - // Enable/Disable submission preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *SubmissionPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type UserRolesPreview struct { - // Enable/Disable user roles preview - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UserRolesPreview) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type OrganizationSettings struct { - AutomationEntityMapping *AutomationEntityMapping `json:"automation_entity_mapping,omitempty"` - AutomationPreview *AutomationPreview `json:"automation_preview,omitempty"` - CentralInboxPreviewSetting *CentralInboxPreviewSetting `json:"central_inbox_preview_setting,omitempty"` - ContractsPreviewSetting *ContractsPreviewSetting `json:"contracts_preview_setting,omitempty"` - DisableIvy *DisableIvy `json:"disable_ivy,omitempty"` - DoubleOptIn *DoubleOptIn `json:"double_opt_in,omitempty"` - EcommerceCatalogPreview *EcommerceCatalogPreview `json:"ecommerce_catalog_preview,omitempty"` - EcommerceOpportunitiesPreview *EcommerceOpportunitiesPreview `json:"ecommerce_opportunities_preview,omitempty"` - EcommercePreview *EcommercePreview `json:"ecommerce_preview,omitempty"` - EndCustomerPortal *EndCustomerPortal `json:"end_customer_portal,omitempty"` - EntitySchemaBuilder *EntitySchemaBuilder `json:"entity_schema_builder,omitempty"` - InstallerPortal *InstallerPortal `json:"installer_portal,omitempty"` - LogicEditorPreview *LogicEditorPreview `json:"logic_editor_preview,omitempty"` - NewNavigation *NewNavigation `json:"new_navigation,omitempty"` - Partnering *Partnering `json:"partnering,omitempty"` - ProductAvailability *ProductAvailability `json:"product-availability,omitempty"` - Sso *Sso `json:"sso,omitempty"` - SubmissionPreview *SubmissionPreview `json:"submission_preview,omitempty"` - UserRolesPreview *UserRolesPreview `json:"user_roles_preview,omitempty"` -} - -func (o *OrganizationSettings) GetAutomationEntityMapping() *AutomationEntityMapping { - if o == nil { - return nil - } - return o.AutomationEntityMapping -} - -func (o *OrganizationSettings) GetAutomationPreview() *AutomationPreview { - if o == nil { - return nil - } - return o.AutomationPreview -} - -func (o *OrganizationSettings) GetCentralInboxPreviewSetting() *CentralInboxPreviewSetting { - if o == nil { - return nil - } - return o.CentralInboxPreviewSetting -} - -func (o *OrganizationSettings) GetContractsPreviewSetting() *ContractsPreviewSetting { - if o == nil { - return nil - } - return o.ContractsPreviewSetting -} - -func (o *OrganizationSettings) GetDisableIvy() *DisableIvy { - if o == nil { - return nil - } - return o.DisableIvy -} - -func (o *OrganizationSettings) GetDoubleOptIn() *DoubleOptIn { - if o == nil { - return nil - } - return o.DoubleOptIn -} - -func (o *OrganizationSettings) GetEcommerceCatalogPreview() *EcommerceCatalogPreview { - if o == nil { - return nil - } - return o.EcommerceCatalogPreview -} - -func (o *OrganizationSettings) GetEcommerceOpportunitiesPreview() *EcommerceOpportunitiesPreview { - if o == nil { - return nil - } - return o.EcommerceOpportunitiesPreview -} - -func (o *OrganizationSettings) GetEcommercePreview() *EcommercePreview { - if o == nil { - return nil - } - return o.EcommercePreview -} - -func (o *OrganizationSettings) GetEndCustomerPortal() *EndCustomerPortal { - if o == nil { - return nil - } - return o.EndCustomerPortal -} - -func (o *OrganizationSettings) GetEntitySchemaBuilder() *EntitySchemaBuilder { - if o == nil { - return nil - } - return o.EntitySchemaBuilder -} - -func (o *OrganizationSettings) GetInstallerPortal() *InstallerPortal { - if o == nil { - return nil - } - return o.InstallerPortal -} - -func (o *OrganizationSettings) GetLogicEditorPreview() *LogicEditorPreview { - if o == nil { - return nil - } - return o.LogicEditorPreview -} - -func (o *OrganizationSettings) GetNewNavigation() *NewNavigation { - if o == nil { - return nil - } - return o.NewNavigation -} - -func (o *OrganizationSettings) GetPartnering() *Partnering { - if o == nil { - return nil - } - return o.Partnering -} - -func (o *OrganizationSettings) GetProductAvailability() *ProductAvailability { - if o == nil { - return nil - } - return o.ProductAvailability -} - -func (o *OrganizationSettings) GetSso() *Sso { - if o == nil { - return nil - } - return o.Sso -} - -func (o *OrganizationSettings) GetSubmissionPreview() *SubmissionPreview { - if o == nil { - return nil - } - return o.SubmissionPreview -} - -func (o *OrganizationSettings) GetUserRolesPreview() *UserRolesPreview { - if o == nil { - return nil - } - return o.UserRolesPreview -} diff --git a/internal/sdk/models/shared/orgrole.go b/internal/sdk/models/shared/orgrole.go new file mode 100644 index 0000000..c48544b --- /dev/null +++ b/internal/sdk/models/shared/orgrole.go @@ -0,0 +1,119 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type OrgRoleType string + +const ( + OrgRoleTypeOrgRole OrgRoleType = "org_role" +) + +func (e OrgRoleType) ToPointer() *OrgRoleType { + return &e +} +func (e *OrgRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "org_role": + *e = OrgRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for OrgRoleType: %v", v) + } +} + +// OrgRole - A role automatically applied to all users in an organization. +type OrgRole struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // The pricing tier of the organization this root role is based on + PricingTier *string `json:"pricing_tier,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type OrgRoleType `json:"type"` +} + +func (o OrgRole) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrgRole) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (o *OrgRole) GetExpiresAt() *time.Time { + if o == nil { + return nil + } + return o.ExpiresAt +} + +func (o *OrgRole) GetGrants() []Grant { + if o == nil { + return []Grant{} + } + return o.Grants +} + +func (o *OrgRole) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *OrgRole) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *OrgRole) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrgRole) GetPricingTier() *string { + if o == nil { + return nil + } + return o.PricingTier +} + +func (o *OrgRole) GetSlug() string { + if o == nil { + return "" + } + return o.Slug +} + +func (o *OrgRole) GetType() OrgRoleType { + if o == nil { + return OrgRoleType("") + } + return o.Type +} diff --git a/internal/sdk/models/shared/page.go b/internal/sdk/models/shared/page.go deleted file mode 100644 index 1272537..0000000 --- a/internal/sdk/models/shared/page.go +++ /dev/null @@ -1,206 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -// PageSchema - The schema of the page -type PageSchema string - -const ( - PageSchemaContact PageSchema = "contact" - PageSchemaContract PageSchema = "contract" - PageSchemaMeter PageSchema = "meter" - PageSchemaOrder PageSchema = "order" - PageSchemaOpportunity PageSchema = "opportunity" - PageSchemaMeterCounter PageSchema = "meter_counter" -) - -func (e PageSchema) ToPointer() *PageSchema { - return &e -} -func (e *PageSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contact": - fallthrough - case "contract": - fallthrough - case "meter": - fallthrough - case "order": - fallthrough - case "opportunity": - fallthrough - case "meter_counter": - *e = PageSchema(v) - return nil - default: - return fmt.Errorf("invalid value for PageSchema: %v", v) - } -} - -type Page struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - Blocks map[string]Block `json:"blocks,omitempty"` - // The content of the page - Content map[string]any `json:"content,omitempty"` - // The design of the page - Design map[string]any `json:"design,omitempty"` - // The id of the page - ID *string `json:"id,omitempty"` - // Send the flag as true to delete the page - IsDeleted *bool `json:"is_deleted,omitempty"` - // Whether the page is the entry route - IsEntryRoute *bool `json:"is_entry_route,omitempty"` - // Whether the page is public - IsPublic *bool `json:"is_public,omitempty"` - // Whether the page is a system page - IsSystem *bool `json:"is_system,omitempty"` - // Last modified timestamp of the Page - LastModifiedAt *time.Time `json:"last_modified_at,omitempty"` - // The order of the block - Order float64 `json:"order"` - // The id of the parent page - ParentID *string `json:"parentId,omitempty"` - // The path of the page - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - Path *string `json:"path,omitempty"` - Schema []PageSchema `json:"schema,omitempty"` - // The slug of the page - Slug string `json:"slug"` - // The conditions that need to be met for the page to be shown - Visibility map[string]any `json:"visibility,omitempty"` -} - -func (p Page) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *Page) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"order", "slug"}); err != nil { - return err - } - return nil -} - -func (o *Page) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Page) GetBlocks() map[string]Block { - if o == nil { - return nil - } - return o.Blocks -} - -func (o *Page) GetContent() map[string]any { - if o == nil { - return nil - } - return o.Content -} - -func (o *Page) GetDesign() map[string]any { - if o == nil { - return nil - } - return o.Design -} - -func (o *Page) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *Page) GetIsDeleted() *bool { - if o == nil { - return nil - } - return o.IsDeleted -} - -func (o *Page) GetIsEntryRoute() *bool { - if o == nil { - return nil - } - return o.IsEntryRoute -} - -func (o *Page) GetIsPublic() *bool { - if o == nil { - return nil - } - return o.IsPublic -} - -func (o *Page) GetIsSystem() *bool { - if o == nil { - return nil - } - return o.IsSystem -} - -func (o *Page) GetLastModifiedAt() *time.Time { - if o == nil { - return nil - } - return o.LastModifiedAt -} - -func (o *Page) GetOrder() float64 { - if o == nil { - return 0.0 - } - return o.Order -} - -func (o *Page) GetParentID() *string { - if o == nil { - return nil - } - return o.ParentID -} - -func (o *Page) GetPath() *string { - if o == nil { - return nil - } - return o.Path -} - -func (o *Page) GetSchema() []PageSchema { - if o == nil { - return nil - } - return o.Schema -} - -func (o *Page) GetSlug() string { - if o == nil { - return "" - } - return o.Slug -} - -func (o *Page) GetVisibility() map[string]any { - if o == nil { - return nil - } - return o.Visibility -} diff --git a/internal/sdk/models/shared/pagerequest.go b/internal/sdk/models/shared/pagerequest.go deleted file mode 100644 index 2949084..0000000 --- a/internal/sdk/models/shared/pagerequest.go +++ /dev/null @@ -1,187 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// PageRequestSchema - The schema of the page -type PageRequestSchema string - -const ( - PageRequestSchemaContact PageRequestSchema = "contact" - PageRequestSchemaContract PageRequestSchema = "contract" - PageRequestSchemaMeter PageRequestSchema = "meter" - PageRequestSchemaOrder PageRequestSchema = "order" - PageRequestSchemaOpportunity PageRequestSchema = "opportunity" - PageRequestSchemaMeterCounter PageRequestSchema = "meter_counter" -) - -func (e PageRequestSchema) ToPointer() *PageRequestSchema { - return &e -} -func (e *PageRequestSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "contact": - fallthrough - case "contract": - fallthrough - case "meter": - fallthrough - case "order": - fallthrough - case "opportunity": - fallthrough - case "meter_counter": - *e = PageRequestSchema(v) - return nil - default: - return fmt.Errorf("invalid value for PageRequestSchema: %v", v) - } -} - -type PageRequest struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - Blocks map[string]Block `json:"blocks,omitempty"` - // The content of the page - Content map[string]any `json:"content,omitempty"` - // The design of the page - Design map[string]any `json:"design,omitempty"` - // Send the flag as true to delete the page - IsDeleted *bool `json:"is_deleted,omitempty"` - // Whether the page is the entry route - IsEntryRoute *bool `json:"is_entry_route,omitempty"` - // Whether the page is public - IsPublic *bool `json:"is_public,omitempty"` - // Whether the page is a system page - IsSystem *bool `json:"is_system,omitempty"` - // The order of the block - Order float64 `json:"order"` - // The id of the parent page - ParentID *string `json:"parentId,omitempty"` - // The path of the page - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - Path *string `json:"path,omitempty"` - Schema []PageRequestSchema `json:"schema,omitempty"` - // The slug of the page - Slug string `json:"slug"` - // The conditions that need to be met for the page to be shown - Visibility map[string]any `json:"visibility,omitempty"` -} - -func (p PageRequest) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *PageRequest) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"order", "slug"}); err != nil { - return err - } - return nil -} - -func (o *PageRequest) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *PageRequest) GetBlocks() map[string]Block { - if o == nil { - return nil - } - return o.Blocks -} - -func (o *PageRequest) GetContent() map[string]any { - if o == nil { - return nil - } - return o.Content -} - -func (o *PageRequest) GetDesign() map[string]any { - if o == nil { - return nil - } - return o.Design -} - -func (o *PageRequest) GetIsDeleted() *bool { - if o == nil { - return nil - } - return o.IsDeleted -} - -func (o *PageRequest) GetIsEntryRoute() *bool { - if o == nil { - return nil - } - return o.IsEntryRoute -} - -func (o *PageRequest) GetIsPublic() *bool { - if o == nil { - return nil - } - return o.IsPublic -} - -func (o *PageRequest) GetIsSystem() *bool { - if o == nil { - return nil - } - return o.IsSystem -} - -func (o *PageRequest) GetOrder() float64 { - if o == nil { - return 0.0 - } - return o.Order -} - -func (o *PageRequest) GetParentID() *string { - if o == nil { - return nil - } - return o.ParentID -} - -func (o *PageRequest) GetPath() *string { - if o == nil { - return nil - } - return o.Path -} - -func (o *PageRequest) GetSchema() []PageRequestSchema { - if o == nil { - return nil - } - return o.Schema -} - -func (o *PageRequest) GetSlug() string { - if o == nil { - return "" - } - return o.Slug -} - -func (o *PageRequest) GetVisibility() map[string]any { - if o == nil { - return nil - } - return o.Visibility -} diff --git a/internal/sdk/models/shared/partnerrole.go b/internal/sdk/models/shared/partnerrole.go new file mode 100644 index 0000000..2136a14 --- /dev/null +++ b/internal/sdk/models/shared/partnerrole.go @@ -0,0 +1,118 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type PartnerRoleType string + +const ( + PartnerRoleTypePartnerRole PartnerRoleType = "partner_role" +) + +func (e PartnerRoleType) ToPointer() *PartnerRoleType { + return &e +} +func (e *PartnerRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "partner_role": + *e = PartnerRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for PartnerRoleType: %v", v) + } +} + +// PartnerRole - A role that appears in another organization's role list that can be assigned but not modified by the partner organization. +type PartnerRole struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + PartnerOrgID *string `json:"partner_org_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type PartnerRoleType `json:"type"` +} + +func (p PartnerRole) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PartnerRole) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (p *PartnerRole) GetExpiresAt() *time.Time { + if p == nil { + return nil + } + return p.ExpiresAt +} + +func (p *PartnerRole) GetGrants() []Grant { + if p == nil { + return []Grant{} + } + return p.Grants +} + +func (p *PartnerRole) GetID() string { + if p == nil { + return "" + } + return p.ID +} + +func (p *PartnerRole) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PartnerRole) GetOrganizationID() string { + if p == nil { + return "" + } + return p.OrganizationID +} + +func (p *PartnerRole) GetPartnerOrgID() *string { + if p == nil { + return nil + } + return p.PartnerOrgID +} + +func (p *PartnerRole) GetSlug() string { + if p == nil { + return "" + } + return p.Slug +} + +func (p *PartnerRole) GetType() PartnerRoleType { + if p == nil { + return PartnerRoleType("") + } + return p.Type +} diff --git a/internal/sdk/models/shared/portalconfig.go b/internal/sdk/models/shared/portalconfig.go deleted file mode 100644 index 729bebe..0000000 --- a/internal/sdk/models/shared/portalconfig.go +++ /dev/null @@ -1,929 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -type AdvancedMfa struct { - // Advanced MFA feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *AdvancedMfa) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type EntryPoint string - -const ( - EntryPointPassword EntryPoint = "PASSWORD" - EntryPointSso EntryPoint = "SSO" -) - -func (e EntryPoint) ToPointer() *EntryPoint { - return &e -} -func (e *EntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = EntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for EntryPoint: %v", v) - } -} - -type PasswordlessLogin struct { - // Passwordless login feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PasswordlessLogin) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// AuthSettings - Authentication settings for the portal -type AuthSettings struct { - // Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. - AutoRedirectToSso *bool `json:"auto_redirect_to_sso,omitempty"` - EntryPoint *EntryPoint `json:"entry_point,omitempty"` - PasswordlessLogin *PasswordlessLogin `json:"passwordless_login,omitempty"` - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` -} - -func (o *AuthSettings) GetAutoRedirectToSso() *bool { - if o == nil { - return nil - } - return o.AutoRedirectToSso -} - -func (o *AuthSettings) GetEntryPoint() *EntryPoint { - if o == nil { - return nil - } - return o.EntryPoint -} - -func (o *AuthSettings) GetPasswordlessLogin() *PasswordlessLogin { - if o == nil { - return nil - } - return o.PasswordlessLogin -} - -func (o *AuthSettings) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -// PasswordPolicy - Password policy for the portal -type PasswordPolicy struct { - // Minimum password length - MinimumLength *int64 `json:"minimum_length,omitempty"` - // Require lowercase characters - RequireLowercase *bool `json:"require_lowercase,omitempty"` - // Require numbers - RequireNumbers *bool `json:"require_numbers,omitempty"` - // Require symbols - RequireSymbols *bool `json:"require_symbols,omitempty"` - // Require uppercase characters - RequireUppercase *bool `json:"require_uppercase,omitempty"` -} - -func (o *PasswordPolicy) GetMinimumLength() *int64 { - if o == nil { - return nil - } - return o.MinimumLength -} - -func (o *PasswordPolicy) GetRequireLowercase() *bool { - if o == nil { - return nil - } - return o.RequireLowercase -} - -func (o *PasswordPolicy) GetRequireNumbers() *bool { - if o == nil { - return nil - } - return o.RequireNumbers -} - -func (o *PasswordPolicy) GetRequireSymbols() *bool { - if o == nil { - return nil - } - return o.RequireSymbols -} - -func (o *PasswordPolicy) GetRequireUppercase() *bool { - if o == nil { - return nil - } - return o.RequireUppercase -} - -// CognitoDetails - AWS Cognito Pool details for the portal -type CognitoDetails struct { - // Cognito user pool ARN - CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` - // Cognito user pool client ID - CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` - // Cognito user pool ID - CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` - // Password policy for the portal - PasswordPolicy *PasswordPolicy `json:"password_policy,omitempty"` -} - -func (o *CognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolArn -} - -func (o *CognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolClientID -} - -func (o *CognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolID -} - -func (o *CognitoDetails) GetPasswordPolicy() *PasswordPolicy { - if o == nil { - return nil - } - return o.PasswordPolicy -} - -// ContractSelectorConfig - Configuration for contract selector in the portal -type ContractSelectorConfig struct { - // Whether to show inactive contracts in the selector - ShowInactive *bool `json:"show_inactive,omitempty"` - // Path to the property to use as the contract title - TitlePath *string `json:"title_path,omitempty"` -} - -func (o *ContractSelectorConfig) GetShowInactive() *bool { - if o == nil { - return nil - } - return o.ShowInactive -} - -func (o *ContractSelectorConfig) GetTitlePath() *string { - if o == nil { - return nil - } - return o.TitlePath -} - -type CadencePeriodType string - -const ( - CadencePeriodTypeDays CadencePeriodType = "days" - CadencePeriodTypeWeeks CadencePeriodType = "weeks" - CadencePeriodTypeMonths CadencePeriodType = "months" -) - -func (e CadencePeriodType) ToPointer() *CadencePeriodType { - return &e -} -func (e *CadencePeriodType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "days": - fallthrough - case "weeks": - fallthrough - case "months": - *e = CadencePeriodType(v) - return nil - default: - return fmt.Errorf("invalid value for CadencePeriodType: %v", v) - } -} - -type RuleType string - -const ( - RuleTypeCadence RuleType = "cadence" - RuleTypeRelativeToCurrentValue RuleType = "relative_to_current_value" - RuleTypeDaysBeforeDate RuleType = "days_before_date" - RuleTypeOverduePayments RuleType = "overdue_payments" -) - -func (e RuleType) ToPointer() *RuleType { - return &e -} -func (e *RuleType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "cadence": - fallthrough - case "relative_to_current_value": - fallthrough - case "days_before_date": - fallthrough - case "overdue_payments": - *e = RuleType(v) - return nil - default: - return fmt.Errorf("invalid value for RuleType: %v", v) - } -} - -type EntityEditRules struct { - AllowedDecrement *string `json:"allowed_decrement,omitempty"` - AllowedIncrement *string `json:"allowed_increment,omitempty"` - Attribute *string `json:"attribute,omitempty"` - CadencePeriod *float64 `json:"cadence_period,omitempty"` - CadencePeriodType *CadencePeriodType `json:"cadence_period_type,omitempty"` - ChangesAllowed *int64 `json:"changes_allowed,omitempty"` - GracePeriod *int64 `json:"grace_period,omitempty"` - NumberOfDaysBeforeRestriction *int64 `json:"number_of_days_before_restriction,omitempty"` - RuleType *RuleType `json:"rule_type,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *EntityEditRules) GetAllowedDecrement() *string { - if o == nil { - return nil - } - return o.AllowedDecrement -} - -func (o *EntityEditRules) GetAllowedIncrement() *string { - if o == nil { - return nil - } - return o.AllowedIncrement -} - -func (o *EntityEditRules) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *EntityEditRules) GetCadencePeriod() *float64 { - if o == nil { - return nil - } - return o.CadencePeriod -} - -func (o *EntityEditRules) GetCadencePeriodType() *CadencePeriodType { - if o == nil { - return nil - } - return o.CadencePeriodType -} - -func (o *EntityEditRules) GetChangesAllowed() *int64 { - if o == nil { - return nil - } - return o.ChangesAllowed -} - -func (o *EntityEditRules) GetGracePeriod() *int64 { - if o == nil { - return nil - } - return o.GracePeriod -} - -func (o *EntityEditRules) GetNumberOfDaysBeforeRestriction() *int64 { - if o == nil { - return nil - } - return o.NumberOfDaysBeforeRestriction -} - -func (o *EntityEditRules) GetRuleType() *RuleType { - if o == nil { - return nil - } - return o.RuleType -} - -func (o *EntityEditRules) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type PortalConfigType struct { - // Attributes used to identify an entity - Attributes []string `json:"attributes,omitempty"` - // Enable/Disable the entity identifier - IsEnabled *bool `json:"isEnabled,omitempty"` -} - -func (o *PortalConfigType) GetAttributes() []string { - if o == nil { - return nil - } - return o.Attributes -} - -func (o *PortalConfigType) GetIsEnabled() *bool { - if o == nil { - return nil - } - return o.IsEnabled -} - -// EntityIdentifiers - Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type EntityIdentifiers struct { - Type *PortalConfigType `json:"type,omitempty"` -} - -func (o *EntityIdentifiers) GetType() *PortalConfigType { - if o == nil { - return nil - } - return o.Type -} - -// FeatureSettings - Feature settings for the portal -type FeatureSettings struct { - // Billing feature flag - Billing *bool `json:"billing,omitempty"` - // Change due date feature flag - ChangeDueDate *bool `json:"change_due_date,omitempty"` - // Enable or disable the new design for the portal - NewDesign *bool `json:"new_design,omitempty"` - // Start page feature flag - StartPage *bool `json:"start_page,omitempty"` -} - -func (o *FeatureSettings) GetBilling() *bool { - if o == nil { - return nil - } - return o.Billing -} - -func (o *FeatureSettings) GetChangeDueDate() *bool { - if o == nil { - return nil - } - return o.ChangeDueDate -} - -func (o *FeatureSettings) GetNewDesign() *bool { - if o == nil { - return nil - } - return o.NewDesign -} - -func (o *FeatureSettings) GetStartPage() *bool { - if o == nil { - return nil - } - return o.StartPage -} - -// Images - Teaser & Banner Image web links -type Images struct { - // URL of the order left teaser image - OrderLeftTeaser *string `json:"orderLeftTeaser,omitempty"` - // URL of the order right teaser image - OrderRightTeaser *string `json:"orderRightTeaser,omitempty"` - // URL of the welcome banner image - WelcomeBanner *string `json:"welcomeBanner,omitempty"` -} - -func (o *Images) GetOrderLeftTeaser() *string { - if o == nil { - return nil - } - return o.OrderLeftTeaser -} - -func (o *Images) GetOrderRightTeaser() *string { - if o == nil { - return nil - } - return o.OrderRightTeaser -} - -func (o *Images) GetWelcomeBanner() *string { - if o == nil { - return nil - } - return o.WelcomeBanner -} - -// Canary feature flag -type Canary struct { - // Enable/Disable the canary feature - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Canary) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// Notracking - Disable Advanced Usage Metrics -type Notracking struct { - // Disable browser-side scripts that track advanced usage metrics - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *Notracking) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// OrgSettings - Organization settings -type OrgSettings struct { - // Canary feature flag - Canary *Canary `json:"canary,omitempty"` - // Disable Advanced Usage Metrics - Notracking *Notracking `json:"notracking,omitempty"` -} - -func (o *OrgSettings) GetCanary() *Canary { - if o == nil { - return nil - } - return o.Canary -} - -func (o *OrgSettings) GetNotracking() *Notracking { - if o == nil { - return nil - } - return o.Notracking -} - -type SelfRegistrationSetting string - -const ( - SelfRegistrationSettingAllowWithContactCreation SelfRegistrationSetting = "ALLOW_WITH_CONTACT_CREATION" - SelfRegistrationSettingAllowWithoutContactCreation SelfRegistrationSetting = "ALLOW_WITHOUT_CONTACT_CREATION" - SelfRegistrationSettingDeny SelfRegistrationSetting = "DENY" -) - -func (e SelfRegistrationSetting) ToPointer() *SelfRegistrationSetting { - return &e -} -func (e *SelfRegistrationSetting) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ALLOW_WITH_CONTACT_CREATION": - fallthrough - case "ALLOW_WITHOUT_CONTACT_CREATION": - fallthrough - case "DENY": - *e = SelfRegistrationSetting(v) - return nil - default: - return fmt.Errorf("invalid value for SelfRegistrationSetting: %v", v) - } -} - -type TriggerName string - -const ( - TriggerNameFirstLogin TriggerName = "FIRST_LOGIN" - TriggerNameAcceptOrder TriggerName = "ACCEPT_ORDER" - TriggerNameDeclineOrder TriggerName = "DECLINE_ORDER" -) - -func (e TriggerName) ToPointer() *TriggerName { - return &e -} -func (e *TriggerName) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "FIRST_LOGIN": - fallthrough - case "ACCEPT_ORDER": - fallthrough - case "DECLINE_ORDER": - *e = TriggerName(v) - return nil - default: - return fmt.Errorf("invalid value for TriggerName: %v", v) - } -} - -type TriggeredJourneys struct { - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - TriggerName *TriggerName `json:"trigger_name,omitempty"` -} - -func (o *TriggeredJourneys) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *TriggeredJourneys) GetTriggerName() *TriggerName { - if o == nil { - return nil - } - return o.TriggerName -} - -type PortalConfig struct { - // Access token for the portal - AccessToken *string `json:"accessToken,omitempty"` - AdvancedMfa *AdvancedMfa `json:"advanced_mfa,omitempty"` - // Allowed file extensions for upload - AllowedFileExtensions *AllowedFileExtensions `json:"allowed_file_extensions,omitempty"` - ApprovalStateAttributes map[string][]string `json:"approval_state_attributes,omitempty"` - // Authentication settings for the portal - AuthSettings *AuthSettings `json:"auth_settings,omitempty"` - // AWS Cognito Pool details for the portal - CognitoDetails *CognitoDetails `json:"cognito_details,omitempty"` - // Stringified object with configuration details - Config *string `json:"config,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers []string `json:"contact_identifiers,omitempty"` - // Identifiers to identify a contract by a portal user. - ContractIdentifiers []ContractIdentifier `json:"contract_identifiers,omitempty"` - // Configuration for contract selector in the portal - ContractSelectorConfig *ContractSelectorConfig `json:"contract_selector_config,omitempty"` - // Entity ID - DesignID *string `json:"design_id,omitempty"` - // The URL on which the portal is accessible - Domain string `json:"domain"` - // Email templates used for authentication and internal processes - EmailTemplates *EmailTemplates `json:"email_templates,omitempty"` - // Enable/Disable the portal access - Enabled *bool `json:"enabled,omitempty"` - // Rules for editing an entity by a portal user - EntityEditRules []EntityEditRules `json:"entity_edit_rules,omitempty"` - // Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - EntityIdentifiers *EntityIdentifiers `json:"entity_identifiers,omitempty"` - // Feature flags for the portal - FeatureFlags map[string]bool `json:"feature_flags,omitempty"` - // Feature settings for the portal - FeatureSettings *FeatureSettings `json:"feature_settings,omitempty"` - // Permissions granted to a portal user while accessing entities - Grants []Grant `json:"grants,omitempty"` - // ID of the organization - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ID *string `json:"id,omitempty"` - IdentityProviders []ProviderPublicConfig `json:"identity_providers,omitempty"` - // Teaser & Banner Image web links - Images *Images `json:"images,omitempty"` - // Number of years to look back for showing inactive contracts in the portal - InactiveContractCutoffYears *float64 `json:"inactive_contract_cutoff_years,omitempty"` - // Whether this is a dummy/test portal configuration - IsDummy *bool `json:"is_dummy,omitempty"` - // Mark true if the domain is an Epilot domain - IsEpilotDomain *bool `json:"is_epilot_domain,omitempty"` - // Whether this is a v3 portal configuration - IsV3Item *bool `json:"is_v3_item,omitempty"` - // Grace period in days for meter readings - MeterReadingGracePeriod *float64 `json:"meter_reading_grace_period,omitempty"` - // A short name to identify your portal - Name *string `json:"name,omitempty"` - // Organization settings - OrgSettings *OrgSettings `json:"org_settings,omitempty"` - // ID of the organization - OrganizationID *string `json:"organization_id,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` - Pages map[string]Page `json:"pages,omitempty"` - // ID of the portal - PortalID *string `json:"portal_id,omitempty"` - // Key of the portal config - PortalSkV3 *string `json:"portal_sk_v3,omitempty"` - // Prevent indexing by search engines - PreventSearchEngineIndexing *bool `json:"prevent_search_engine_indexing,omitempty"` - // Identifiers to identify a contact of a portal user during the registration. - RegistrationIdentifiers []ContractIdentifier `json:"registration_identifiers,omitempty"` - SelfRegistrationSetting *SelfRegistrationSetting `json:"self_registration_setting,omitempty"` - // Journeys automatically opened on a portal user action - TriggeredJourneys []TriggeredJourneys `json:"triggered_journeys,omitempty"` -} - -func (o *PortalConfig) GetAccessToken() *string { - if o == nil { - return nil - } - return o.AccessToken -} - -func (o *PortalConfig) GetAdvancedMfa() *AdvancedMfa { - if o == nil { - return nil - } - return o.AdvancedMfa -} - -func (o *PortalConfig) GetAllowedFileExtensions() *AllowedFileExtensions { - if o == nil { - return nil - } - return o.AllowedFileExtensions -} - -func (o *PortalConfig) GetApprovalStateAttributes() map[string][]string { - if o == nil { - return nil - } - return o.ApprovalStateAttributes -} - -func (o *PortalConfig) GetAuthSettings() *AuthSettings { - if o == nil { - return nil - } - return o.AuthSettings -} - -func (o *PortalConfig) GetCognitoDetails() *CognitoDetails { - if o == nil { - return nil - } - return o.CognitoDetails -} - -func (o *PortalConfig) GetConfig() *string { - if o == nil { - return nil - } - return o.Config -} - -func (o *PortalConfig) GetContactIdentifiers() []string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *PortalConfig) GetContractIdentifiers() []ContractIdentifier { - if o == nil { - return nil - } - return o.ContractIdentifiers -} - -func (o *PortalConfig) GetContractSelectorConfig() *ContractSelectorConfig { - if o == nil { - return nil - } - return o.ContractSelectorConfig -} - -func (o *PortalConfig) GetDesignID() *string { - if o == nil { - return nil - } - return o.DesignID -} - -func (o *PortalConfig) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *PortalConfig) GetEmailTemplates() *EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *PortalConfig) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *PortalConfig) GetEntityEditRules() []EntityEditRules { - if o == nil { - return nil - } - return o.EntityEditRules -} - -func (o *PortalConfig) GetEntityIdentifiers() *EntityIdentifiers { - if o == nil { - return nil - } - return o.EntityIdentifiers -} - -func (o *PortalConfig) GetFeatureFlags() map[string]bool { - if o == nil { - return nil - } - return o.FeatureFlags -} - -func (o *PortalConfig) GetFeatureSettings() *FeatureSettings { - if o == nil { - return nil - } - return o.FeatureSettings -} - -func (o *PortalConfig) GetGrants() []Grant { - if o == nil { - return nil - } - return o.Grants -} - -func (o *PortalConfig) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *PortalConfig) GetIdentityProviders() []ProviderPublicConfig { - if o == nil { - return nil - } - return o.IdentityProviders -} - -func (o *PortalConfig) GetImages() *Images { - if o == nil { - return nil - } - return o.Images -} - -func (o *PortalConfig) GetInactiveContractCutoffYears() *float64 { - if o == nil { - return nil - } - return o.InactiveContractCutoffYears -} - -func (o *PortalConfig) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} - -func (o *PortalConfig) GetIsEpilotDomain() *bool { - if o == nil { - return nil - } - return o.IsEpilotDomain -} - -func (o *PortalConfig) GetIsV3Item() *bool { - if o == nil { - return nil - } - return o.IsV3Item -} - -func (o *PortalConfig) GetMeterReadingGracePeriod() *float64 { - if o == nil { - return nil - } - return o.MeterReadingGracePeriod -} - -func (o *PortalConfig) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *PortalConfig) GetOrgSettings() *OrgSettings { - if o == nil { - return nil - } - return o.OrgSettings -} - -func (o *PortalConfig) GetOrganizationID() *string { - if o == nil { - return nil - } - return o.OrganizationID -} - -func (o *PortalConfig) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -func (o *PortalConfig) GetPages() map[string]Page { - if o == nil { - return nil - } - return o.Pages -} - -func (o *PortalConfig) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -func (o *PortalConfig) GetPortalSkV3() *string { - if o == nil { - return nil - } - return o.PortalSkV3 -} - -func (o *PortalConfig) GetPreventSearchEngineIndexing() *bool { - if o == nil { - return nil - } - return o.PreventSearchEngineIndexing -} - -func (o *PortalConfig) GetRegistrationIdentifiers() []ContractIdentifier { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} - -func (o *PortalConfig) GetSelfRegistrationSetting() *SelfRegistrationSetting { - if o == nil { - return nil - } - return o.SelfRegistrationSetting -} - -func (o *PortalConfig) GetTriggeredJourneys() []TriggeredJourneys { - if o == nil { - return nil - } - return o.TriggeredJourneys -} diff --git a/internal/sdk/models/shared/portalconfigv3.go b/internal/sdk/models/shared/portalconfigv3.go deleted file mode 100644 index 3b8a733..0000000 --- a/internal/sdk/models/shared/portalconfigv3.go +++ /dev/null @@ -1,870 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -type PortalConfigV3AdvancedMfa struct { - // Advanced MFA feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PortalConfigV3AdvancedMfa) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type PortalConfigV3EntryPoint string - -const ( - PortalConfigV3EntryPointPassword PortalConfigV3EntryPoint = "PASSWORD" - PortalConfigV3EntryPointSso PortalConfigV3EntryPoint = "SSO" -) - -func (e PortalConfigV3EntryPoint) ToPointer() *PortalConfigV3EntryPoint { - return &e -} -func (e *PortalConfigV3EntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = PortalConfigV3EntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for PortalConfigV3EntryPoint: %v", v) - } -} - -type PortalConfigV3PasswordlessLogin struct { - // Passwordless login feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PortalConfigV3PasswordlessLogin) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// PortalConfigV3AuthSettings - Authentication settings for the portal -type PortalConfigV3AuthSettings struct { - // Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. - AutoRedirectToSso *bool `json:"auto_redirect_to_sso,omitempty"` - EntryPoint *PortalConfigV3EntryPoint `json:"entry_point,omitempty"` - PasswordlessLogin *PortalConfigV3PasswordlessLogin `json:"passwordless_login,omitempty"` - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` -} - -func (o *PortalConfigV3AuthSettings) GetAutoRedirectToSso() *bool { - if o == nil { - return nil - } - return o.AutoRedirectToSso -} - -func (o *PortalConfigV3AuthSettings) GetEntryPoint() *PortalConfigV3EntryPoint { - if o == nil { - return nil - } - return o.EntryPoint -} - -func (o *PortalConfigV3AuthSettings) GetPasswordlessLogin() *PortalConfigV3PasswordlessLogin { - if o == nil { - return nil - } - return o.PasswordlessLogin -} - -func (o *PortalConfigV3AuthSettings) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -// PortalConfigV3PasswordPolicy - Password policy for the portal -type PortalConfigV3PasswordPolicy struct { - // Minimum password length - MinimumLength *int64 `json:"minimum_length,omitempty"` - // Require lowercase characters - RequireLowercase *bool `json:"require_lowercase,omitempty"` - // Require numbers - RequireNumbers *bool `json:"require_numbers,omitempty"` - // Require symbols - RequireSymbols *bool `json:"require_symbols,omitempty"` - // Require uppercase characters - RequireUppercase *bool `json:"require_uppercase,omitempty"` -} - -func (o *PortalConfigV3PasswordPolicy) GetMinimumLength() *int64 { - if o == nil { - return nil - } - return o.MinimumLength -} - -func (o *PortalConfigV3PasswordPolicy) GetRequireLowercase() *bool { - if o == nil { - return nil - } - return o.RequireLowercase -} - -func (o *PortalConfigV3PasswordPolicy) GetRequireNumbers() *bool { - if o == nil { - return nil - } - return o.RequireNumbers -} - -func (o *PortalConfigV3PasswordPolicy) GetRequireSymbols() *bool { - if o == nil { - return nil - } - return o.RequireSymbols -} - -func (o *PortalConfigV3PasswordPolicy) GetRequireUppercase() *bool { - if o == nil { - return nil - } - return o.RequireUppercase -} - -// PortalConfigV3CognitoDetails - AWS Cognito Pool details for the portal -type PortalConfigV3CognitoDetails struct { - // Cognito user pool ARN - CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` - // Cognito user pool client ID - CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` - // Cognito user pool ID - CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` - // Password policy for the portal - PasswordPolicy *PortalConfigV3PasswordPolicy `json:"password_policy,omitempty"` -} - -func (o *PortalConfigV3CognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolArn -} - -func (o *PortalConfigV3CognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolClientID -} - -func (o *PortalConfigV3CognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolID -} - -func (o *PortalConfigV3CognitoDetails) GetPasswordPolicy() *PortalConfigV3PasswordPolicy { - if o == nil { - return nil - } - return o.PasswordPolicy -} - -// PortalConfigV3ContractSelectorConfig - Configuration for contract selector in the portal -type PortalConfigV3ContractSelectorConfig struct { - // Whether to show inactive contracts in the selector - ShowInactive *bool `json:"show_inactive,omitempty"` - // Path to the property to use as the contract title - TitlePath *string `json:"title_path,omitempty"` -} - -func (o *PortalConfigV3ContractSelectorConfig) GetShowInactive() *bool { - if o == nil { - return nil - } - return o.ShowInactive -} - -func (o *PortalConfigV3ContractSelectorConfig) GetTitlePath() *string { - if o == nil { - return nil - } - return o.TitlePath -} - -// DefaultUserToNotify - Default 360 user to notify upon an internal notification -type DefaultUserToNotify struct { - // Default admin users for pending user notification to notify - OnPendingUser []AdminUser `json:"onPendingUser,omitempty"` -} - -func (o *DefaultUserToNotify) GetOnPendingUser() []AdminUser { - if o == nil { - return nil - } - return o.OnPendingUser -} - -type PortalConfigV3ActionLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (o *PortalConfigV3ActionLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *PortalConfigV3ActionLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type EntityActions struct { - ActionLabel *PortalConfigV3ActionLabel `json:"action_Label,omitempty"` - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *EntityActions) GetActionLabel() *PortalConfigV3ActionLabel { - if o == nil { - return nil - } - return o.ActionLabel -} - -func (o *EntityActions) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *EntityActions) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type PortalConfigV3Type struct { - // Attributes used to identify an entity - Attributes []string `json:"attributes,omitempty"` - // Enable/Disable the entity identifier - IsEnabled *bool `json:"isEnabled,omitempty"` -} - -func (o *PortalConfigV3Type) GetAttributes() []string { - if o == nil { - return nil - } - return o.Attributes -} - -func (o *PortalConfigV3Type) GetIsEnabled() *bool { - if o == nil { - return nil - } - return o.IsEnabled -} - -// PortalConfigV3EntityIdentifiers - Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type PortalConfigV3EntityIdentifiers struct { - Type *PortalConfigV3Type `json:"type,omitempty"` -} - -func (o *PortalConfigV3EntityIdentifiers) GetType() *PortalConfigV3Type { - if o == nil { - return nil - } - return o.Type -} - -// PortalConfigV3FeatureSettings - Feature settings for the portal -type PortalConfigV3FeatureSettings struct { - // Billing feature flag - Billing *bool `json:"billing,omitempty"` - // Change due date feature flag - ChangeDueDate *bool `json:"change_due_date,omitempty"` - // Enable or disable the new design for the portal - NewDesign *bool `json:"new_design,omitempty"` - // Start page feature flag - StartPage *bool `json:"start_page,omitempty"` -} - -func (o *PortalConfigV3FeatureSettings) GetBilling() *bool { - if o == nil { - return nil - } - return o.Billing -} - -func (o *PortalConfigV3FeatureSettings) GetChangeDueDate() *bool { - if o == nil { - return nil - } - return o.ChangeDueDate -} - -func (o *PortalConfigV3FeatureSettings) GetNewDesign() *bool { - if o == nil { - return nil - } - return o.NewDesign -} - -func (o *PortalConfigV3FeatureSettings) GetStartPage() *bool { - if o == nil { - return nil - } - return o.StartPage -} - -// PortalConfigV3Images - Teaser & Banner Image web links -type PortalConfigV3Images struct { - // URL of the order left teaser image - OrderLeftTeaser *string `json:"orderLeftTeaser,omitempty"` - // URL of the order right teaser image - OrderRightTeaser *string `json:"orderRightTeaser,omitempty"` - // URL of the welcome banner image - WelcomeBanner *string `json:"welcomeBanner,omitempty"` -} - -func (o *PortalConfigV3Images) GetOrderLeftTeaser() *string { - if o == nil { - return nil - } - return o.OrderLeftTeaser -} - -func (o *PortalConfigV3Images) GetOrderRightTeaser() *string { - if o == nil { - return nil - } - return o.OrderRightTeaser -} - -func (o *PortalConfigV3Images) GetWelcomeBanner() *string { - if o == nil { - return nil - } - return o.WelcomeBanner -} - -// PortalConfigV3Canary - Canary feature flag -type PortalConfigV3Canary struct { - // Enable/Disable the canary feature - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PortalConfigV3Canary) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// PortalConfigV3Notracking - Disable Advanced Usage Metrics -type PortalConfigV3Notracking struct { - // Disable browser-side scripts that track advanced usage metrics - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *PortalConfigV3Notracking) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// PortalConfigV3OrgSettings - Organization settings -type PortalConfigV3OrgSettings struct { - // Canary feature flag - Canary *PortalConfigV3Canary `json:"canary,omitempty"` - // Disable Advanced Usage Metrics - Notracking *PortalConfigV3Notracking `json:"notracking,omitempty"` -} - -func (o *PortalConfigV3OrgSettings) GetCanary() *PortalConfigV3Canary { - if o == nil { - return nil - } - return o.Canary -} - -func (o *PortalConfigV3OrgSettings) GetNotracking() *PortalConfigV3Notracking { - if o == nil { - return nil - } - return o.Notracking -} - -type PortalConfigV3SelfRegistrationSetting string - -const ( - PortalConfigV3SelfRegistrationSettingAllowWithContactCreation PortalConfigV3SelfRegistrationSetting = "ALLOW_WITH_CONTACT_CREATION" - PortalConfigV3SelfRegistrationSettingAllowWithoutContactCreation PortalConfigV3SelfRegistrationSetting = "ALLOW_WITHOUT_CONTACT_CREATION" - PortalConfigV3SelfRegistrationSettingDeny PortalConfigV3SelfRegistrationSetting = "DENY" -) - -func (e PortalConfigV3SelfRegistrationSetting) ToPointer() *PortalConfigV3SelfRegistrationSetting { - return &e -} -func (e *PortalConfigV3SelfRegistrationSetting) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ALLOW_WITH_CONTACT_CREATION": - fallthrough - case "ALLOW_WITHOUT_CONTACT_CREATION": - fallthrough - case "DENY": - *e = PortalConfigV3SelfRegistrationSetting(v) - return nil - default: - return fmt.Errorf("invalid value for PortalConfigV3SelfRegistrationSetting: %v", v) - } -} - -type PortalConfigV3TriggerName string - -const ( - PortalConfigV3TriggerNameFirstLogin PortalConfigV3TriggerName = "FIRST_LOGIN" - PortalConfigV3TriggerNameAcceptOrder PortalConfigV3TriggerName = "ACCEPT_ORDER" - PortalConfigV3TriggerNameDeclineOrder PortalConfigV3TriggerName = "DECLINE_ORDER" -) - -func (e PortalConfigV3TriggerName) ToPointer() *PortalConfigV3TriggerName { - return &e -} -func (e *PortalConfigV3TriggerName) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "FIRST_LOGIN": - fallthrough - case "ACCEPT_ORDER": - fallthrough - case "DECLINE_ORDER": - *e = PortalConfigV3TriggerName(v) - return nil - default: - return fmt.Errorf("invalid value for PortalConfigV3TriggerName: %v", v) - } -} - -type PortalConfigV3TriggeredJourneys struct { - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - TriggerName *PortalConfigV3TriggerName `json:"trigger_name,omitempty"` -} - -func (o *PortalConfigV3TriggeredJourneys) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *PortalConfigV3TriggeredJourneys) GetTriggerName() *PortalConfigV3TriggerName { - if o == nil { - return nil - } - return o.TriggerName -} - -type PortalConfigV3 struct { - // Access token for the portal - AccessToken *string `json:"accessToken,omitempty"` - AdvancedMfa *PortalConfigV3AdvancedMfa `json:"advanced_mfa,omitempty"` - // Allowed file extensions for upload - AllowedFileExtensions *AllowedFileExtensions `json:"allowed_file_extensions,omitempty"` - ApprovalStateAttributes any `json:"approval_state_attributes,omitempty"` - // Authentication settings for the portal - AuthSettings *PortalConfigV3AuthSettings `json:"auth_settings,omitempty"` - // AWS Cognito Pool details for the portal - CognitoDetails *PortalConfigV3CognitoDetails `json:"cognito_details,omitempty"` - // Stringified object with configuration details - Config *string `json:"config,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers []string `json:"contact_identifiers,omitempty"` - // Identifiers to identify a contract by a portal user. - ContractIdentifiers any `json:"contract_identifiers,omitempty"` - // Configuration for contract selector in the portal - ContractSelectorConfig *PortalConfigV3ContractSelectorConfig `json:"contract_selector_config,omitempty"` - // Default 360 user to notify upon an internal notification - DefaultUserToNotify *DefaultUserToNotify `json:"default_user_to_notify,omitempty"` - // Entity ID - DesignID *string `json:"design_id,omitempty"` - // The URL on which the portal is accessible - Domain *string `json:"domain,omitempty"` - // Email templates used for authentication and internal processes - EmailTemplates *EmailTemplates `json:"email_templates,omitempty"` - // Enable/Disable the portal access - Enabled *bool `json:"enabled,omitempty"` - // Journey actions allowed on an entity by a portal user - EntityActions []EntityActions `json:"entity_actions,omitempty"` - // Rules for editing an entity by a portal user - EntityEditRules any `json:"entity_edit_rules,omitempty"` - // Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - EntityIdentifiers *PortalConfigV3EntityIdentifiers `json:"entity_identifiers,omitempty"` - // Configured Portal extensions hooks - ExtensionHooks map[string]*ExtensionHookConfig `json:"extension_hooks,omitempty"` - // Configured Portal extensions - Extensions []ExtensionConfig `json:"extensions,omitempty"` - // Feature flags for the portal - FeatureFlags any `json:"feature_flags,omitempty"` - // Feature settings for the portal - FeatureSettings *PortalConfigV3FeatureSettings `json:"feature_settings,omitempty"` - // Permissions granted to a portal user while accessing entities - Grants any `json:"grants,omitempty"` - IdentityProviders any `json:"identity_providers,omitempty"` - // Teaser & Banner Image web links - Images *PortalConfigV3Images `json:"images,omitempty"` - // Number of years to look back for showing inactive contracts in the portal - InactiveContractCutoffYears *float64 `json:"inactive_contract_cutoff_years,omitempty"` - // Whether this is a dummy/test portal configuration - IsDummy *bool `json:"is_dummy,omitempty"` - // Mark true if the domain is an Epilot domain - IsEpilotDomain *bool `json:"is_epilot_domain,omitempty"` - // Whether this is a v3 portal configuration - IsV3Item *bool `json:"is_v3_item,omitempty"` - // Grace period in days for meter readings - MeterReadingGracePeriod *float64 `json:"meter_reading_grace_period,omitempty"` - // A short name to identify your portal - Name *string `json:"name,omitempty"` - // Organization settings - OrgSettings *PortalConfigV3OrgSettings `json:"org_settings,omitempty"` - // ID of the organization - OrganizationID *string `json:"organization_id,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` - Pages any `json:"pages,omitempty"` - // ID of the portal - PortalID *string `json:"portal_id,omitempty"` - // Key of the portal config - PortalSkV3 *string `json:"portal_sk_v3,omitempty"` - // Prevent indexing by search engines - PreventSearchEngineIndexing *bool `json:"prevent_search_engine_indexing,omitempty"` - // Identifiers to identify a contact of a portal user during the registration. - RegistrationIdentifiers any `json:"registration_identifiers,omitempty"` - SelfRegistrationSetting *PortalConfigV3SelfRegistrationSetting `json:"self_registration_setting,omitempty"` - // Journeys automatically opened on a portal user action - TriggeredJourneys []PortalConfigV3TriggeredJourneys `json:"triggered_journeys,omitempty"` -} - -func (o *PortalConfigV3) GetAccessToken() *string { - if o == nil { - return nil - } - return o.AccessToken -} - -func (o *PortalConfigV3) GetAdvancedMfa() *PortalConfigV3AdvancedMfa { - if o == nil { - return nil - } - return o.AdvancedMfa -} - -func (o *PortalConfigV3) GetAllowedFileExtensions() *AllowedFileExtensions { - if o == nil { - return nil - } - return o.AllowedFileExtensions -} - -func (o *PortalConfigV3) GetApprovalStateAttributes() any { - if o == nil { - return nil - } - return o.ApprovalStateAttributes -} - -func (o *PortalConfigV3) GetAuthSettings() *PortalConfigV3AuthSettings { - if o == nil { - return nil - } - return o.AuthSettings -} - -func (o *PortalConfigV3) GetCognitoDetails() *PortalConfigV3CognitoDetails { - if o == nil { - return nil - } - return o.CognitoDetails -} - -func (o *PortalConfigV3) GetConfig() *string { - if o == nil { - return nil - } - return o.Config -} - -func (o *PortalConfigV3) GetContactIdentifiers() []string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *PortalConfigV3) GetContractIdentifiers() any { - if o == nil { - return nil - } - return o.ContractIdentifiers -} - -func (o *PortalConfigV3) GetContractSelectorConfig() *PortalConfigV3ContractSelectorConfig { - if o == nil { - return nil - } - return o.ContractSelectorConfig -} - -func (o *PortalConfigV3) GetDefaultUserToNotify() *DefaultUserToNotify { - if o == nil { - return nil - } - return o.DefaultUserToNotify -} - -func (o *PortalConfigV3) GetDesignID() *string { - if o == nil { - return nil - } - return o.DesignID -} - -func (o *PortalConfigV3) GetDomain() *string { - if o == nil { - return nil - } - return o.Domain -} - -func (o *PortalConfigV3) GetEmailTemplates() *EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *PortalConfigV3) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *PortalConfigV3) GetEntityActions() []EntityActions { - if o == nil { - return nil - } - return o.EntityActions -} - -func (o *PortalConfigV3) GetEntityEditRules() any { - if o == nil { - return nil - } - return o.EntityEditRules -} - -func (o *PortalConfigV3) GetEntityIdentifiers() *PortalConfigV3EntityIdentifiers { - if o == nil { - return nil - } - return o.EntityIdentifiers -} - -func (o *PortalConfigV3) GetExtensionHooks() map[string]*ExtensionHookConfig { - if o == nil { - return nil - } - return o.ExtensionHooks -} - -func (o *PortalConfigV3) GetExtensions() []ExtensionConfig { - if o == nil { - return nil - } - return o.Extensions -} - -func (o *PortalConfigV3) GetFeatureFlags() any { - if o == nil { - return nil - } - return o.FeatureFlags -} - -func (o *PortalConfigV3) GetFeatureSettings() *PortalConfigV3FeatureSettings { - if o == nil { - return nil - } - return o.FeatureSettings -} - -func (o *PortalConfigV3) GetGrants() any { - if o == nil { - return nil - } - return o.Grants -} - -func (o *PortalConfigV3) GetIdentityProviders() any { - if o == nil { - return nil - } - return o.IdentityProviders -} - -func (o *PortalConfigV3) GetImages() *PortalConfigV3Images { - if o == nil { - return nil - } - return o.Images -} - -func (o *PortalConfigV3) GetInactiveContractCutoffYears() *float64 { - if o == nil { - return nil - } - return o.InactiveContractCutoffYears -} - -func (o *PortalConfigV3) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} - -func (o *PortalConfigV3) GetIsEpilotDomain() *bool { - if o == nil { - return nil - } - return o.IsEpilotDomain -} - -func (o *PortalConfigV3) GetIsV3Item() *bool { - if o == nil { - return nil - } - return o.IsV3Item -} - -func (o *PortalConfigV3) GetMeterReadingGracePeriod() *float64 { - if o == nil { - return nil - } - return o.MeterReadingGracePeriod -} - -func (o *PortalConfigV3) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *PortalConfigV3) GetOrgSettings() *PortalConfigV3OrgSettings { - if o == nil { - return nil - } - return o.OrgSettings -} - -func (o *PortalConfigV3) GetOrganizationID() *string { - if o == nil { - return nil - } - return o.OrganizationID -} - -func (o *PortalConfigV3) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -func (o *PortalConfigV3) GetPages() any { - if o == nil { - return nil - } - return o.Pages -} - -func (o *PortalConfigV3) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -func (o *PortalConfigV3) GetPortalSkV3() *string { - if o == nil { - return nil - } - return o.PortalSkV3 -} - -func (o *PortalConfigV3) GetPreventSearchEngineIndexing() *bool { - if o == nil { - return nil - } - return o.PreventSearchEngineIndexing -} - -func (o *PortalConfigV3) GetRegistrationIdentifiers() any { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} - -func (o *PortalConfigV3) GetSelfRegistrationSetting() *PortalConfigV3SelfRegistrationSetting { - if o == nil { - return nil - } - return o.SelfRegistrationSetting -} - -func (o *PortalConfigV3) GetTriggeredJourneys() []PortalConfigV3TriggeredJourneys { - if o == nil { - return nil - } - return o.TriggeredJourneys -} diff --git a/internal/sdk/models/shared/portalrole.go b/internal/sdk/models/shared/portalrole.go new file mode 100644 index 0000000..3f7ae5a --- /dev/null +++ b/internal/sdk/models/shared/portalrole.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type PortalRoleType string + +const ( + PortalRoleTypePortalRole PortalRoleType = "portal_role" +) + +func (e PortalRoleType) ToPointer() *PortalRoleType { + return &e +} +func (e *PortalRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "portal_role": + *e = PortalRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for PortalRoleType: %v", v) + } +} + +// PortalRole - A role that is applied to end customers and installers using the Portals +type PortalRole struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type PortalRoleType `json:"type"` +} + +func (p PortalRole) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PortalRole) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (p *PortalRole) GetExpiresAt() *time.Time { + if p == nil { + return nil + } + return p.ExpiresAt +} + +func (p *PortalRole) GetGrants() []Grant { + if p == nil { + return []Grant{} + } + return p.Grants +} + +func (p *PortalRole) GetID() string { + if p == nil { + return "" + } + return p.ID +} + +func (p *PortalRole) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PortalRole) GetOrganizationID() string { + if p == nil { + return "" + } + return p.OrganizationID +} + +func (p *PortalRole) GetSlug() string { + if p == nil { + return "" + } + return p.Slug +} + +func (p *PortalRole) GetType() PortalRoleType { + if p == nil { + return PortalRoleType("") + } + return p.Type +} diff --git a/internal/sdk/models/shared/portaluser.go b/internal/sdk/models/shared/portaluser.go deleted file mode 100644 index d2b520f..0000000 --- a/internal/sdk/models/shared/portaluser.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type PortalUserSchema string - -const ( - PortalUserSchemaPortalUser PortalUserSchema = "portal_user" -) - -func (e PortalUserSchema) ToPointer() *PortalUserSchema { - return &e -} -func (e *PortalUserSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "portal_user": - *e = PortalUserSchema(v) - return nil - default: - return fmt.Errorf("invalid value for PortalUserSchema: %v", v) - } -} - -// PortalUser - The portal user entity -type PortalUser struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema PortalUserSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (p PortalUser) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *PortalUser) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *PortalUser) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *PortalUser) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *PortalUser) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *PortalUser) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *PortalUser) GetSchema() PortalUserSchema { - if o == nil { - return PortalUserSchema("") - } - return o.Schema -} - -func (o *PortalUser) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *PortalUser) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *PortalUser) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/product.go b/internal/sdk/models/shared/product.go deleted file mode 100644 index ed69dad..0000000 --- a/internal/sdk/models/shared/product.go +++ /dev/null @@ -1,118 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "time" -) - -type ProductSchema string - -const ( - ProductSchemaProduct ProductSchema = "product" -) - -func (e ProductSchema) ToPointer() *ProductSchema { - return &e -} -func (e *ProductSchema) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "product": - *e = ProductSchema(v) - return nil - default: - return fmt.Errorf("invalid value for ProductSchema: %v", v) - } -} - -// Product - The product entity -type Product struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Creation timestamp of the entity - CreatedAt time.Time `json:"_created_at"` - // Entity ID - ID string `json:"_id"` - // Organization ID the entity belongs to - Org string `json:"_org"` - Schema ProductSchema `json:"_schema"` - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Title of the entity - Title string `json:"_title"` - // Last update timestamp of the entity - UpdatedAt time.Time `json:"_updated_at"` -} - -func (p Product) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *Product) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"_created_at", "_id", "_org", "_schema", "_title", "_updated_at"}); err != nil { - return err - } - return nil -} - -func (o *Product) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Product) GetCreatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.CreatedAt -} - -func (o *Product) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *Product) GetOrg() string { - if o == nil { - return "" - } - return o.Org -} - -func (o *Product) GetSchema() ProductSchema { - if o == nil { - return ProductSchema("") - } - return o.Schema -} - -func (o *Product) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *Product) GetTitle() string { - if o == nil { - return "" - } - return o.Title -} - -func (o *Product) GetUpdatedAt() time.Time { - if o == nil { - return time.Time{} - } - return o.UpdatedAt -} diff --git a/internal/sdk/models/shared/providerpublicconfig.go b/internal/sdk/models/shared/providerpublicconfig.go deleted file mode 100644 index 2909af9..0000000 --- a/internal/sdk/models/shared/providerpublicconfig.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ProviderPublicConfig struct { - // Human-readable display name for identity provider shown in login - DisplayName string `json:"display_name"` - MobileOidcConfig *MoblieOIDCConfig `json:"mobile_oidc_config,omitempty"` - OidcConfig *OIDCProviderConfig `json:"oidc_config,omitempty"` - // URL-friendly slug to use as organization-unique identifier for Provider - Slug string `json:"slug"` -} - -func (o *ProviderPublicConfig) GetDisplayName() string { - if o == nil { - return "" - } - return o.DisplayName -} - -func (o *ProviderPublicConfig) GetMobileOidcConfig() *MoblieOIDCConfig { - if o == nil { - return nil - } - return o.MobileOidcConfig -} - -func (o *ProviderPublicConfig) GetOidcConfig() *OIDCProviderConfig { - if o == nil { - return nil - } - return o.OidcConfig -} - -func (o *ProviderPublicConfig) GetSlug() string { - if o == nil { - return "" - } - return o.Slug -} diff --git a/internal/sdk/models/shared/publiccontractidentificationdetails.go b/internal/sdk/models/shared/publiccontractidentificationdetails.go deleted file mode 100644 index 7539eaa..0000000 --- a/internal/sdk/models/shared/publiccontractidentificationdetails.go +++ /dev/null @@ -1,51 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// PublicContractIdentificationDetailsExplanation - Explanation of the hook. -type PublicContractIdentificationDetailsExplanation struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Explanation of the functionality shown to the end user. - En string `json:"en"` -} - -func (p PublicContractIdentificationDetailsExplanation) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *PublicContractIdentificationDetailsExplanation) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *PublicContractIdentificationDetailsExplanation) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *PublicContractIdentificationDetailsExplanation) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type PublicContractIdentificationDetails struct { - // Explanation of the hook. - Explanation *PublicContractIdentificationDetailsExplanation `json:"explanation,omitempty"` -} - -func (o *PublicContractIdentificationDetails) GetExplanation() *PublicContractIdentificationDetailsExplanation { - if o == nil { - return nil - } - return o.Explanation -} diff --git a/internal/sdk/models/shared/publicdataretrievalhookdetails.go b/internal/sdk/models/shared/publicdataretrievalhookdetails.go deleted file mode 100644 index 38d7f15..0000000 --- a/internal/sdk/models/shared/publicdataretrievalhookdetails.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type PublicDataRetrievalHookDetailsName struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (p PublicDataRetrievalHookDetailsName) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *PublicDataRetrievalHookDetailsName) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *PublicDataRetrievalHookDetailsName) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *PublicDataRetrievalHookDetailsName) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type PublicDataRetrievalHookDetails struct { - // Identifier of the hook. - ID *string `json:"id,omitempty"` - // The intervals associated with the hook. - Intervals []string `json:"intervals,omitempty"` - Name *PublicDataRetrievalHookDetailsName `json:"name,omitempty"` -} - -func (o *PublicDataRetrievalHookDetails) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *PublicDataRetrievalHookDetails) GetIntervals() []string { - if o == nil { - return nil - } - return o.Intervals -} - -func (o *PublicDataRetrievalHookDetails) GetName() *PublicDataRetrievalHookDetailsName { - if o == nil { - return nil - } - return o.Name -} diff --git a/internal/sdk/models/shared/publicextensioncapabilities.go b/internal/sdk/models/shared/publicextensioncapabilities.go deleted file mode 100644 index 0d844a7..0000000 --- a/internal/sdk/models/shared/publicextensioncapabilities.go +++ /dev/null @@ -1,57 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type ContractIdentification struct { - Extension *PublicExtensionDetails `json:"extension,omitempty"` - Hook *PublicContractIdentificationDetails `json:"hook,omitempty"` -} - -func (o *ContractIdentification) GetExtension() *PublicExtensionDetails { - if o == nil { - return nil - } - return o.Extension -} - -func (o *ContractIdentification) GetHook() *PublicContractIdentificationDetails { - if o == nil { - return nil - } - return o.Hook -} - -type PublicExtensionCapabilities struct { - ConsumptionDataRetrieval []DataRetrievalItem `json:"consumptionDataRetrieval,omitempty"` - ContractIdentification *ContractIdentification `json:"contractIdentification,omitempty"` - CostDataRetrieval []DataRetrievalItem `json:"costDataRetrieval,omitempty"` - PriceDataRetrieval []DataRetrievalItem `json:"priceDataRetrieval,omitempty"` -} - -func (o *PublicExtensionCapabilities) GetConsumptionDataRetrieval() []DataRetrievalItem { - if o == nil { - return nil - } - return o.ConsumptionDataRetrieval -} - -func (o *PublicExtensionCapabilities) GetContractIdentification() *ContractIdentification { - if o == nil { - return nil - } - return o.ContractIdentification -} - -func (o *PublicExtensionCapabilities) GetCostDataRetrieval() []DataRetrievalItem { - if o == nil { - return nil - } - return o.CostDataRetrieval -} - -func (o *PublicExtensionCapabilities) GetPriceDataRetrieval() []DataRetrievalItem { - if o == nil { - return nil - } - return o.PriceDataRetrieval -} diff --git a/internal/sdk/models/shared/publicextensiondetails.go b/internal/sdk/models/shared/publicextensiondetails.go deleted file mode 100644 index 6cca24d..0000000 --- a/internal/sdk/models/shared/publicextensiondetails.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type PublicExtensionDetailsName struct { - AdditionalProperties map[string]string `additionalProperties:"true" json:"-"` - // Name of the extension in English. - En string `json:"en"` -} - -func (p PublicExtensionDetailsName) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(p, "", false) -} - -func (p *PublicExtensionDetailsName) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &p, "", false, []string{"en"}); err != nil { - return err - } - return nil -} - -func (o *PublicExtensionDetailsName) GetAdditionalProperties() map[string]string { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *PublicExtensionDetailsName) GetEn() string { - if o == nil { - return "" - } - return o.En -} - -type PublicExtensionDetails struct { - // Identifier of the extension. - ID *string `json:"id,omitempty"` - Name *PublicExtensionDetailsName `json:"name,omitempty"` -} - -func (o *PublicExtensionDetails) GetID() *string { - if o == nil { - return nil - } - return o.ID -} - -func (o *PublicExtensionDetails) GetName() *PublicExtensionDetailsName { - if o == nil { - return nil - } - return o.Name -} diff --git a/internal/sdk/models/shared/role.go b/internal/sdk/models/shared/role.go new file mode 100644 index 0000000..9eea7c1 --- /dev/null +++ b/internal/sdk/models/shared/role.go @@ -0,0 +1,176 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "errors" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" +) + +type RoleType string + +const ( + RoleTypeUserRole RoleType = "UserRole" + RoleTypeOrgRole RoleType = "OrgRole" + RoleTypeShareRole RoleType = "ShareRole" + RoleTypePartnerRole RoleType = "PartnerRole" + RoleTypePortalRole RoleType = "PortalRole" +) + +type Role struct { + UserRole *UserRole `queryParam:"inline,name=Role"` + OrgRole *OrgRole `queryParam:"inline,name=Role"` + ShareRole *ShareRole `queryParam:"inline,name=Role"` + PartnerRole *PartnerRole `queryParam:"inline,name=Role"` + PortalRole *PortalRole `queryParam:"inline,name=Role"` + + Type RoleType +} + +func CreateRoleUserRole(userRole UserRole) Role { + typ := RoleTypeUserRole + + return Role{ + UserRole: &userRole, + Type: typ, + } +} + +func CreateRoleOrgRole(orgRole OrgRole) Role { + typ := RoleTypeOrgRole + + return Role{ + OrgRole: &orgRole, + Type: typ, + } +} + +func CreateRoleShareRole(shareRole ShareRole) Role { + typ := RoleTypeShareRole + + return Role{ + ShareRole: &shareRole, + Type: typ, + } +} + +func CreateRolePartnerRole(partnerRole PartnerRole) Role { + typ := RoleTypePartnerRole + + return Role{ + PartnerRole: &partnerRole, + Type: typ, + } +} + +func CreateRolePortalRole(portalRole PortalRole) Role { + typ := RoleTypePortalRole + + return Role{ + PortalRole: &portalRole, + Type: typ, + } +} + +func (u *Role) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var userRole UserRole = UserRole{} + if err := utils.UnmarshalJSON(data, &userRole, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RoleTypeUserRole, + Value: &userRole, + }) + } + + var orgRole OrgRole = OrgRole{} + if err := utils.UnmarshalJSON(data, &orgRole, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RoleTypeOrgRole, + Value: &orgRole, + }) + } + + var shareRole ShareRole = ShareRole{} + if err := utils.UnmarshalJSON(data, &shareRole, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RoleTypeShareRole, + Value: &shareRole, + }) + } + + var partnerRole PartnerRole = PartnerRole{} + if err := utils.UnmarshalJSON(data, &partnerRole, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RoleTypePartnerRole, + Value: &partnerRole, + }) + } + + var portalRole PortalRole = PortalRole{} + if err := utils.UnmarshalJSON(data, &portalRole, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RoleTypePortalRole, + Value: &portalRole, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Role", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Role", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(RoleType) + switch best.Type { + case RoleTypeUserRole: + u.UserRole = best.Value.(*UserRole) + return nil + case RoleTypeOrgRole: + u.OrgRole = best.Value.(*OrgRole) + return nil + case RoleTypeShareRole: + u.ShareRole = best.Value.(*ShareRole) + return nil + case RoleTypePartnerRole: + u.PartnerRole = best.Value.(*PartnerRole) + return nil + case RoleTypePortalRole: + u.PortalRole = best.Value.(*PortalRole) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Role", string(data)) +} + +func (u Role) MarshalJSON() ([]byte, error) { + if u.UserRole != nil { + return utils.MarshalJSON(u.UserRole, "", true) + } + + if u.OrgRole != nil { + return utils.MarshalJSON(u.OrgRole, "", true) + } + + if u.ShareRole != nil { + return utils.MarshalJSON(u.ShareRole, "", true) + } + + if u.PartnerRole != nil { + return utils.MarshalJSON(u.PartnerRole, "", true) + } + + if u.PortalRole != nil { + return utils.MarshalJSON(u.PortalRole, "", true) + } + + return nil, errors.New("could not marshal union type Role: all fields are null") +} diff --git a/internal/sdk/models/shared/rolepayload.go b/internal/sdk/models/shared/rolepayload.go new file mode 100644 index 0000000..5add262 --- /dev/null +++ b/internal/sdk/models/shared/rolepayload.go @@ -0,0 +1,690 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type SchemasPortalRoleType string + +const ( + SchemasPortalRoleTypePortalRole SchemasPortalRoleType = "portal_role" +) + +func (e SchemasPortalRoleType) ToPointer() *SchemasPortalRoleType { + return &e +} +func (e *SchemasPortalRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "portal_role": + *e = SchemasPortalRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for SchemasPortalRoleType: %v", v) + } +} + +// PortalRoleSchemas - A role that is applied to end customers and installers using the Portals +type PortalRoleSchemas struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Grants []GrantWithDependencies `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type SchemasPortalRoleType `json:"type"` +} + +func (p PortalRoleSchemas) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PortalRoleSchemas) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (p *PortalRoleSchemas) GetExpiresAt() *time.Time { + if p == nil { + return nil + } + return p.ExpiresAt +} + +func (p *PortalRoleSchemas) GetGrants() []GrantWithDependencies { + if p == nil { + return []GrantWithDependencies{} + } + return p.Grants +} + +func (p *PortalRoleSchemas) GetID() string { + if p == nil { + return "" + } + return p.ID +} + +func (p *PortalRoleSchemas) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PortalRoleSchemas) GetOrganizationID() string { + if p == nil { + return "" + } + return p.OrganizationID +} + +func (p *PortalRoleSchemas) GetSlug() string { + if p == nil { + return "" + } + return p.Slug +} + +func (p *PortalRoleSchemas) GetType() SchemasPortalRoleType { + if p == nil { + return SchemasPortalRoleType("") + } + return p.Type +} + +type SchemasType string + +const ( + SchemasTypePartnerRole SchemasType = "partner_role" +) + +func (e SchemasType) ToPointer() *SchemasType { + return &e +} +func (e *SchemasType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "partner_role": + *e = SchemasType(v) + return nil + default: + return fmt.Errorf("invalid value for SchemasType: %v", v) + } +} + +// PartnerRoleSchemas - A role that appears in another organization's role list that can be assigned but not modified by the partner organization. +type PartnerRoleSchemas struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Grants []GrantWithDependencies `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + PartnerOrgID *string `json:"partner_org_id,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type SchemasType `json:"type"` +} + +func (p PartnerRoleSchemas) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PartnerRoleSchemas) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (p *PartnerRoleSchemas) GetExpiresAt() *time.Time { + if p == nil { + return nil + } + return p.ExpiresAt +} + +func (p *PartnerRoleSchemas) GetGrants() []GrantWithDependencies { + if p == nil { + return []GrantWithDependencies{} + } + return p.Grants +} + +func (p *PartnerRoleSchemas) GetID() string { + if p == nil { + return "" + } + return p.ID +} + +func (p *PartnerRoleSchemas) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PartnerRoleSchemas) GetOrganizationID() string { + if p == nil { + return "" + } + return p.OrganizationID +} + +func (p *PartnerRoleSchemas) GetPartnerOrgID() *string { + if p == nil { + return nil + } + return p.PartnerOrgID +} + +func (p *PartnerRoleSchemas) GetSlug() string { + if p == nil { + return "" + } + return p.Slug +} + +func (p *PartnerRoleSchemas) GetType() SchemasType { + if p == nil { + return SchemasType("") + } + return p.Type +} + +type SchemasShareRoleType string + +const ( + SchemasShareRoleTypeShareRole SchemasShareRoleType = "share_role" +) + +func (e SchemasShareRoleType) ToPointer() *SchemasShareRoleType { + return &e +} +func (e *SchemasShareRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "share_role": + *e = SchemasShareRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for SchemasShareRoleType: %v", v) + } +} + +// ShareRoleSchemas - A role that can be assigned to users in other organizations for sharing purposes. +type ShareRoleSchemas struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Grants []GrantWithDependencies `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type SchemasShareRoleType `json:"type"` +} + +func (s ShareRoleSchemas) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *ShareRoleSchemas) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (s *ShareRoleSchemas) GetExpiresAt() *time.Time { + if s == nil { + return nil + } + return s.ExpiresAt +} + +func (s *ShareRoleSchemas) GetGrants() []GrantWithDependencies { + if s == nil { + return []GrantWithDependencies{} + } + return s.Grants +} + +func (s *ShareRoleSchemas) GetID() string { + if s == nil { + return "" + } + return s.ID +} + +func (s *ShareRoleSchemas) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *ShareRoleSchemas) GetOrganizationID() string { + if s == nil { + return "" + } + return s.OrganizationID +} + +func (s *ShareRoleSchemas) GetSlug() string { + if s == nil { + return "" + } + return s.Slug +} + +func (s *ShareRoleSchemas) GetType() SchemasShareRoleType { + if s == nil { + return SchemasShareRoleType("") + } + return s.Type +} + +type Type string + +const ( + TypeOrgRole Type = "org_role" +) + +func (e Type) ToPointer() *Type { + return &e +} +func (e *Type) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "org_role": + *e = Type(v) + return nil + default: + return fmt.Errorf("invalid value for Type: %v", v) + } +} + +// Schemas - A role automatically applied to all users in an organization. +type Schemas struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Grants []GrantWithDependencies `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // The pricing tier of the organization this root role is based on + PricingTier *string `json:"pricing_tier,omitempty"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type Type `json:"type"` +} + +func (s Schemas) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Schemas) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (s *Schemas) GetExpiresAt() *time.Time { + if s == nil { + return nil + } + return s.ExpiresAt +} + +func (s *Schemas) GetGrants() []GrantWithDependencies { + if s == nil { + return []GrantWithDependencies{} + } + return s.Grants +} + +func (s *Schemas) GetID() string { + if s == nil { + return "" + } + return s.ID +} + +func (s *Schemas) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *Schemas) GetOrganizationID() string { + if s == nil { + return "" + } + return s.OrganizationID +} + +func (s *Schemas) GetPricingTier() *string { + if s == nil { + return nil + } + return s.PricingTier +} + +func (s *Schemas) GetSlug() string { + if s == nil { + return "" + } + return s.Slug +} + +func (s *Schemas) GetType() Type { + if s == nil { + return Type("") + } + return s.Type +} + +type SchemasUserRoleType string + +const ( + SchemasUserRoleTypeUserRole SchemasUserRoleType = "user_role" +) + +func (e SchemasUserRoleType) ToPointer() *SchemasUserRoleType { + return &e +} +func (e *SchemasUserRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "user_role": + *e = SchemasUserRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for SchemasUserRoleType: %v", v) + } +} + +// UserRoleSchemas - A standard user role. Must be explicitly assigned to users. +type UserRoleSchemas struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Grants []GrantWithDependencies `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type SchemasUserRoleType `json:"type"` +} + +func (u UserRoleSchemas) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UserRoleSchemas) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (u *UserRoleSchemas) GetExpiresAt() *time.Time { + if u == nil { + return nil + } + return u.ExpiresAt +} + +func (u *UserRoleSchemas) GetGrants() []GrantWithDependencies { + if u == nil { + return []GrantWithDependencies{} + } + return u.Grants +} + +func (u *UserRoleSchemas) GetID() string { + if u == nil { + return "" + } + return u.ID +} + +func (u *UserRoleSchemas) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *UserRoleSchemas) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UserRoleSchemas) GetSlug() string { + if u == nil { + return "" + } + return u.Slug +} + +func (u *UserRoleSchemas) GetType() SchemasUserRoleType { + if u == nil { + return SchemasUserRoleType("") + } + return u.Type +} + +type RolePayloadType string + +const ( + RolePayloadTypeUserRoleSchemas RolePayloadType = "UserRole_Schemas" + RolePayloadTypeSchemas RolePayloadType = "Schemas" + RolePayloadTypeShareRoleSchemas RolePayloadType = "ShareRole_Schemas" + RolePayloadTypePartnerRoleSchemas RolePayloadType = "PartnerRole_Schemas" + RolePayloadTypePortalRoleSchemas RolePayloadType = "PortalRole_Schemas" +) + +type RolePayload struct { + UserRoleSchemas *UserRoleSchemas `queryParam:"inline,name=RolePayload"` + Schemas *Schemas `queryParam:"inline,name=RolePayload"` + ShareRoleSchemas *ShareRoleSchemas `queryParam:"inline,name=RolePayload"` + PartnerRoleSchemas *PartnerRoleSchemas `queryParam:"inline,name=RolePayload"` + PortalRoleSchemas *PortalRoleSchemas `queryParam:"inline,name=RolePayload"` + + Type RolePayloadType +} + +func CreateRolePayloadUserRoleSchemas(userRoleSchemas UserRoleSchemas) RolePayload { + typ := RolePayloadTypeUserRoleSchemas + + return RolePayload{ + UserRoleSchemas: &userRoleSchemas, + Type: typ, + } +} + +func CreateRolePayloadSchemas(schemas Schemas) RolePayload { + typ := RolePayloadTypeSchemas + + return RolePayload{ + Schemas: &schemas, + Type: typ, + } +} + +func CreateRolePayloadShareRoleSchemas(shareRoleSchemas ShareRoleSchemas) RolePayload { + typ := RolePayloadTypeShareRoleSchemas + + return RolePayload{ + ShareRoleSchemas: &shareRoleSchemas, + Type: typ, + } +} + +func CreateRolePayloadPartnerRoleSchemas(partnerRoleSchemas PartnerRoleSchemas) RolePayload { + typ := RolePayloadTypePartnerRoleSchemas + + return RolePayload{ + PartnerRoleSchemas: &partnerRoleSchemas, + Type: typ, + } +} + +func CreateRolePayloadPortalRoleSchemas(portalRoleSchemas PortalRoleSchemas) RolePayload { + typ := RolePayloadTypePortalRoleSchemas + + return RolePayload{ + PortalRoleSchemas: &portalRoleSchemas, + Type: typ, + } +} + +func (u *RolePayload) UnmarshalJSON(data []byte) error { + + var candidates []utils.UnionCandidate + + // Collect all valid candidates + var userRoleSchemas UserRoleSchemas = UserRoleSchemas{} + if err := utils.UnmarshalJSON(data, &userRoleSchemas, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RolePayloadTypeUserRoleSchemas, + Value: &userRoleSchemas, + }) + } + + var schemas Schemas = Schemas{} + if err := utils.UnmarshalJSON(data, &schemas, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RolePayloadTypeSchemas, + Value: &schemas, + }) + } + + var shareRoleSchemas ShareRoleSchemas = ShareRoleSchemas{} + if err := utils.UnmarshalJSON(data, &shareRoleSchemas, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RolePayloadTypeShareRoleSchemas, + Value: &shareRoleSchemas, + }) + } + + var partnerRoleSchemas PartnerRoleSchemas = PartnerRoleSchemas{} + if err := utils.UnmarshalJSON(data, &partnerRoleSchemas, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RolePayloadTypePartnerRoleSchemas, + Value: &partnerRoleSchemas, + }) + } + + var portalRoleSchemas PortalRoleSchemas = PortalRoleSchemas{} + if err := utils.UnmarshalJSON(data, &portalRoleSchemas, "", true, nil); err == nil { + candidates = append(candidates, utils.UnionCandidate{ + Type: RolePayloadTypePortalRoleSchemas, + Value: &portalRoleSchemas, + }) + } + + if len(candidates) == 0 { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for RolePayload", string(data)) + } + + // Pick the best candidate using multi-stage filtering + best := utils.PickBestCandidate(candidates) + if best == nil { + return fmt.Errorf("could not unmarshal `%s` into any supported union types for RolePayload", string(data)) + } + + // Set the union type and value based on the best candidate + u.Type = best.Type.(RolePayloadType) + switch best.Type { + case RolePayloadTypeUserRoleSchemas: + u.UserRoleSchemas = best.Value.(*UserRoleSchemas) + return nil + case RolePayloadTypeSchemas: + u.Schemas = best.Value.(*Schemas) + return nil + case RolePayloadTypeShareRoleSchemas: + u.ShareRoleSchemas = best.Value.(*ShareRoleSchemas) + return nil + case RolePayloadTypePartnerRoleSchemas: + u.PartnerRoleSchemas = best.Value.(*PartnerRoleSchemas) + return nil + case RolePayloadTypePortalRoleSchemas: + u.PortalRoleSchemas = best.Value.(*PortalRoleSchemas) + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for RolePayload", string(data)) +} + +func (u RolePayload) MarshalJSON() ([]byte, error) { + if u.UserRoleSchemas != nil { + return utils.MarshalJSON(u.UserRoleSchemas, "", true) + } + + if u.Schemas != nil { + return utils.MarshalJSON(u.Schemas, "", true) + } + + if u.ShareRoleSchemas != nil { + return utils.MarshalJSON(u.ShareRoleSchemas, "", true) + } + + if u.PartnerRoleSchemas != nil { + return utils.MarshalJSON(u.PartnerRoleSchemas, "", true) + } + + if u.PortalRoleSchemas != nil { + return utils.MarshalJSON(u.PortalRoleSchemas, "", true) + } + + return nil, errors.New("could not marshal union type RolePayload: all fields are null") +} diff --git a/internal/sdk/models/shared/rolesearchinput.go b/internal/sdk/models/shared/rolesearchinput.go new file mode 100644 index 0000000..64a26b5 --- /dev/null +++ b/internal/sdk/models/shared/rolesearchinput.go @@ -0,0 +1,75 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" +) + +type RoleSearchInput struct { + // The Number of roles to return + Limit *float64 `default:"50" json:"limit"` + // The number of roles to skip before starting to collect the result set + Offset *float64 `default:"0" json:"offset"` + // List of organization ids to filter by + OrgIds []string `json:"org_ids,omitempty"` + // Input to search across fields + Query *string `json:"query,omitempty"` + // List of role ids to filter by + RoleIds []string `json:"role_ids,omitempty"` + // List of role slugs to filter by + Slugs []string `json:"slugs,omitempty"` +} + +func (r RoleSearchInput) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *RoleSearchInput) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *RoleSearchInput) GetLimit() *float64 { + if r == nil { + return nil + } + return r.Limit +} + +func (r *RoleSearchInput) GetOffset() *float64 { + if r == nil { + return nil + } + return r.Offset +} + +func (r *RoleSearchInput) GetOrgIds() []string { + if r == nil { + return nil + } + return r.OrgIds +} + +func (r *RoleSearchInput) GetQuery() *string { + if r == nil { + return nil + } + return r.Query +} + +func (r *RoleSearchInput) GetRoleIds() []string { + if r == nil { + return nil + } + return r.RoleIds +} + +func (r *RoleSearchInput) GetSlugs() []string { + if r == nil { + return nil + } + return r.Slugs +} diff --git a/internal/sdk/models/shared/rule.go b/internal/sdk/models/shared/rule.go deleted file mode 100644 index afdc414..0000000 --- a/internal/sdk/models/shared/rule.go +++ /dev/null @@ -1,45 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Rule struct { - Attribute *string `json:"attribute,omitempty"` - AttributeValue *string `json:"attribute_value,omitempty"` - Entity *string `json:"entity,omitempty"` -} - -func (r Rule) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(r, "", false) -} - -func (r *Rule) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Rule) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *Rule) GetAttributeValue() *string { - if o == nil { - return nil - } - return o.AttributeValue -} - -func (o *Rule) GetEntity() *string { - if o == nil { - return nil - } - return o.Entity -} diff --git a/internal/sdk/models/shared/saveentityfile.go b/internal/sdk/models/shared/saveentityfile.go deleted file mode 100644 index acf7b0c..0000000 --- a/internal/sdk/models/shared/saveentityfile.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -// SaveEntityFileAccessControl - Access control level for the file. Deprecated - all files are private. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type SaveEntityFileAccessControl string - -const ( - SaveEntityFileAccessControlPrivate SaveEntityFileAccessControl = "private" - SaveEntityFileAccessControlPublicRead SaveEntityFileAccessControl = "public-read" -) - -func (e SaveEntityFileAccessControl) ToPointer() *SaveEntityFileAccessControl { - return &e -} -func (e *SaveEntityFileAccessControl) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "private": - fallthrough - case "public-read": - *e = SaveEntityFileAccessControl(v) - return nil - default: - return fmt.Errorf("invalid value for SaveEntityFileAccessControl: %v", v) - } -} - -type SaveEntityFileS3ref struct { - // S3 bucket name - Bucket string `json:"bucket"` - // S3 key - Key string `json:"key"` -} - -func (o *SaveEntityFileS3ref) GetBucket() string { - if o == nil { - return "" - } - return o.Bucket -} - -func (o *SaveEntityFileS3ref) GetKey() string { - if o == nil { - return "" - } - return o.Key -} - -type Files struct { - // Access control level for the file. Deprecated - all files are private. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - AccessControl *SaveEntityFileAccessControl `default:"private" json:"access_control"` - // File name - Filename string `json:"filename"` - S3ref SaveEntityFileS3ref `json:"s3ref"` -} - -func (f Files) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(f, "", false) -} - -func (f *Files) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &f, "", false, []string{"filename", "s3ref"}); err != nil { - return err - } - return nil -} - -func (o *Files) GetAccessControl() *SaveEntityFileAccessControl { - if o == nil { - return nil - } - return o.AccessControl -} - -func (o *Files) GetFilename() string { - if o == nil { - return "" - } - return o.Filename -} - -func (o *Files) GetS3ref() SaveEntityFileS3ref { - if o == nil { - return SaveEntityFileS3ref{} - } - return o.S3ref -} - -type SaveEntityFile struct { - // Entity ID - EntityID string `json:"entity_id"` - // Entity type - EntityType string `json:"entity_type"` - Files []Files `json:"files"` -} - -func (o *SaveEntityFile) GetEntityID() string { - if o == nil { - return "" - } - return o.EntityID -} - -func (o *SaveEntityFile) GetEntityType() string { - if o == nil { - return "" - } - return o.EntityType -} - -func (o *SaveEntityFile) GetFiles() []Files { - if o == nil { - return []Files{} - } - return o.Files -} diff --git a/internal/sdk/models/shared/saveportalfile.go b/internal/sdk/models/shared/saveportalfile.go deleted file mode 100644 index 192b6bc..0000000 --- a/internal/sdk/models/shared/saveportalfile.go +++ /dev/null @@ -1,82 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type SavePortalFileS3ref struct { - // S3 bucket name - Bucket string `json:"bucket"` - // S3 key - Key string `json:"key"` -} - -func (o *SavePortalFileS3ref) GetBucket() string { - if o == nil { - return "" - } - return o.Bucket -} - -func (o *SavePortalFileS3ref) GetKey() string { - if o == nil { - return "" - } - return o.Key -} - -type SavePortalFileFiles struct { - // Array of file tags - Tags []string `json:"_tags,omitempty"` - // File type - FileType string `json:"file_type"` - // File name - Filename *string `json:"filename,omitempty"` - S3ref *SavePortalFileS3ref `json:"s3ref,omitempty"` -} - -func (o *SavePortalFileFiles) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *SavePortalFileFiles) GetFileType() string { - if o == nil { - return "" - } - return o.FileType -} - -func (o *SavePortalFileFiles) GetFilename() *string { - if o == nil { - return nil - } - return o.Filename -} - -func (o *SavePortalFileFiles) GetS3ref() *SavePortalFileS3ref { - if o == nil { - return nil - } - return o.S3ref -} - -type SavePortalFile struct { - Files []SavePortalFileFiles `json:"files"` - // Origin of the portal - Origin string `json:"origin"` -} - -func (o *SavePortalFile) GetFiles() []SavePortalFileFiles { - if o == nil { - return []SavePortalFileFiles{} - } - return o.Files -} - -func (o *SavePortalFile) GetOrigin() string { - if o == nil { - return "" - } - return o.Origin -} diff --git a/internal/sdk/models/shared/schema.go b/internal/sdk/models/shared/schema.go deleted file mode 100644 index 3c701d4..0000000 --- a/internal/sdk/models/shared/schema.go +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Schema struct { - AdditionalProperties any `additionalProperties:"true" json:"-"` - // Slug of the schema - Slug *string `json:"slug,omitempty"` -} - -func (s Schema) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(s, "", false) -} - -func (s *Schema) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Schema) GetAdditionalProperties() any { - if o == nil { - return nil - } - return o.AdditionalProperties -} - -func (o *Schema) GetSlug() *string { - if o == nil { - return nil - } - return o.Slug -} diff --git a/internal/sdk/models/shared/security.go b/internal/sdk/models/shared/security.go index d96d576..d393ff1 100644 --- a/internal/sdk/models/shared/security.go +++ b/internal/sdk/models/shared/security.go @@ -3,28 +3,20 @@ package shared type Security struct { - EitherAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` EpilotAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` - PortalAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` + EpilotOrg *string `security:"scheme,type=apiKey,subtype=header,name=x-epilot-org-id"` } -func (o *Security) GetEitherAuth() *string { - if o == nil { +func (s *Security) GetEpilotAuth() *string { + if s == nil { return nil } - return o.EitherAuth + return s.EpilotAuth } -func (o *Security) GetEpilotAuth() *string { - if o == nil { +func (s *Security) GetEpilotOrg() *string { + if s == nil { return nil } - return o.EpilotAuth -} - -func (o *Security) GetPortalAuth() *string { - if o == nil { - return nil - } - return o.PortalAuth + return s.EpilotOrg } diff --git a/internal/sdk/models/shared/sharerole.go b/internal/sdk/models/shared/sharerole.go new file mode 100644 index 0000000..ef61c62 --- /dev/null +++ b/internal/sdk/models/shared/sharerole.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type ShareRoleType string + +const ( + ShareRoleTypeShareRole ShareRoleType = "share_role" +) + +func (e ShareRoleType) ToPointer() *ShareRoleType { + return &e +} +func (e *ShareRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "share_role": + *e = ShareRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for ShareRoleType: %v", v) + } +} + +// ShareRole - A role that can be assigned to users in other organizations for sharing purposes. +type ShareRole struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type ShareRoleType `json:"type"` +} + +func (s ShareRole) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *ShareRole) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (s *ShareRole) GetExpiresAt() *time.Time { + if s == nil { + return nil + } + return s.ExpiresAt +} + +func (s *ShareRole) GetGrants() []Grant { + if s == nil { + return []Grant{} + } + return s.Grants +} + +func (s *ShareRole) GetID() string { + if s == nil { + return "" + } + return s.ID +} + +func (s *ShareRole) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *ShareRole) GetOrganizationID() string { + if s == nil { + return "" + } + return s.OrganizationID +} + +func (s *ShareRole) GetSlug() string { + if s == nil { + return "" + } + return s.Slug +} + +func (s *ShareRole) GetType() ShareRoleType { + if s == nil { + return ShareRoleType("") + } + return s.Type +} diff --git a/internal/sdk/models/shared/ssocallbackrequest.go b/internal/sdk/models/shared/ssocallbackrequest.go deleted file mode 100644 index 3b9b0c2..0000000 --- a/internal/sdk/models/shared/ssocallbackrequest.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type SSOCallbackRequest struct { - // The client id - ClientID string `json:"client_id"` - // The code received from the external SSO provider - Code string `json:"code"` - // The code verifier - CodeVerifier string `json:"code_verifier"` - // The grant type - GrantType string `json:"grant_type"` - // URL-friendly slug to use as organization-unique identifier for Provider - ProviderSlug *string `json:"provider_slug,omitempty"` - // The redirect uri - RedirectURI string `json:"redirect_uri"` - // URL of the authorization endpoint - TokenEndpoint string `json:"token_endpoint"` -} - -func (o *SSOCallbackRequest) GetClientID() string { - if o == nil { - return "" - } - return o.ClientID -} - -func (o *SSOCallbackRequest) GetCode() string { - if o == nil { - return "" - } - return o.Code -} - -func (o *SSOCallbackRequest) GetCodeVerifier() string { - if o == nil { - return "" - } - return o.CodeVerifier -} - -func (o *SSOCallbackRequest) GetGrantType() string { - if o == nil { - return "" - } - return o.GrantType -} - -func (o *SSOCallbackRequest) GetProviderSlug() *string { - if o == nil { - return nil - } - return o.ProviderSlug -} - -func (o *SSOCallbackRequest) GetRedirectURI() string { - if o == nil { - return "" - } - return o.RedirectURI -} - -func (o *SSOCallbackRequest) GetTokenEndpoint() string { - if o == nil { - return "" - } - return o.TokenEndpoint -} diff --git a/internal/sdk/models/shared/ssocallbackresponse.go b/internal/sdk/models/shared/ssocallbackresponse.go deleted file mode 100644 index 433ef43..0000000 --- a/internal/sdk/models/shared/ssocallbackresponse.go +++ /dev/null @@ -1,60 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type SSOCallbackResponse struct { - // The access token - AccessToken string `json:"access_token"` - // The expires in - ExpiresIn float64 `json:"expires_in"` - // The id token - IDToken *string `json:"id_token,omitempty"` - // The refresh token - RefreshToken string `json:"refresh_token"` - // The scope of the access token - Scope *string `json:"scope,omitempty"` - // The token type - TokenType string `json:"token_type"` -} - -func (o *SSOCallbackResponse) GetAccessToken() string { - if o == nil { - return "" - } - return o.AccessToken -} - -func (o *SSOCallbackResponse) GetExpiresIn() float64 { - if o == nil { - return 0.0 - } - return o.ExpiresIn -} - -func (o *SSOCallbackResponse) GetIDToken() *string { - if o == nil { - return nil - } - return o.IDToken -} - -func (o *SSOCallbackResponse) GetRefreshToken() string { - if o == nil { - return "" - } - return o.RefreshToken -} - -func (o *SSOCallbackResponse) GetScope() *string { - if o == nil { - return nil - } - return o.Scope -} - -func (o *SSOCallbackResponse) GetTokenType() string { - if o == nil { - return "" - } - return o.TokenType -} diff --git a/internal/sdk/models/shared/swappableconfig.go b/internal/sdk/models/shared/swappableconfig.go deleted file mode 100644 index c26e95c..0000000 --- a/internal/sdk/models/shared/swappableconfig.go +++ /dev/null @@ -1,40 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -type SwappableConfig string - -const ( - SwappableConfigAll SwappableConfig = "all" - SwappableConfigDomain SwappableConfig = "domain" - SwappableConfigUsers SwappableConfig = "users" - SwappableConfigEmailTemplates SwappableConfig = "email_templates" -) - -func (e SwappableConfig) ToPointer() *SwappableConfig { - return &e -} -func (e *SwappableConfig) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "all": - fallthrough - case "domain": - fallthrough - case "users": - fallthrough - case "email_templates": - *e = SwappableConfig(v) - return nil - default: - return fmt.Errorf("invalid value for SwappableConfig: %v", v) - } -} diff --git a/internal/sdk/models/shared/teaserwidget.go b/internal/sdk/models/shared/teaserwidget.go deleted file mode 100644 index 23900eb..0000000 --- a/internal/sdk/models/shared/teaserwidget.go +++ /dev/null @@ -1,247 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type TeaserWidgetLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (t TeaserWidgetLabel) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *TeaserWidgetLabel) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *TeaserWidgetLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *TeaserWidgetLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type TeaserWidgetButton struct { - Label *TeaserWidgetLabel `json:"label,omitempty"` - URL *string `json:"url,omitempty"` -} - -func (t TeaserWidgetButton) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *TeaserWidgetButton) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *TeaserWidgetButton) GetLabel() *TeaserWidgetLabel { - if o == nil { - return nil - } - return o.Label -} - -func (o *TeaserWidgetButton) GetURL() *string { - if o == nil { - return nil - } - return o.URL -} - -type TeaserWidgetHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (t TeaserWidgetHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *TeaserWidgetHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *TeaserWidgetHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *TeaserWidgetHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type TeaserWidgetSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (t TeaserWidgetSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *TeaserWidgetSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *TeaserWidgetSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *TeaserWidgetSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type TeaserWidgetType string - -const ( - TeaserWidgetTypeActionWidget TeaserWidgetType = "ACTION_WIDGET" - TeaserWidgetTypeContentWidget TeaserWidgetType = "CONTENT_WIDGET" - TeaserWidgetTypeEntityWidget TeaserWidgetType = "ENTITY_WIDGET" - TeaserWidgetTypeTeaserWidget TeaserWidgetType = "TEASER_WIDGET" - TeaserWidgetTypeDocumentWidget TeaserWidgetType = "DOCUMENT_WIDGET" - TeaserWidgetTypePaymentWidget TeaserWidgetType = "PAYMENT_WIDGET" - TeaserWidgetTypeMeterReadingWidget TeaserWidgetType = "METER_READING_WIDGET" - TeaserWidgetTypeMeterChartWidget TeaserWidgetType = "METER_CHART_WIDGET" - TeaserWidgetTypeCampaignWidget TeaserWidgetType = "CAMPAIGN_WIDGET" -) - -func (e TeaserWidgetType) ToPointer() *TeaserWidgetType { - return &e -} -func (e *TeaserWidgetType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = TeaserWidgetType(v) - return nil - default: - return fmt.Errorf("invalid value for TeaserWidgetType: %v", v) - } -} - -type TeaserWidget struct { - Button *TeaserWidgetButton `json:"button,omitempty"` - Headline *TeaserWidgetHeadline `json:"headline,omitempty"` - ID string `json:"id"` - ImageURL *string `json:"imageUrl,omitempty"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - SubHeadline *TeaserWidgetSubHeadline `json:"subHeadline,omitempty"` - Type TeaserWidgetType `json:"type"` -} - -func (t TeaserWidget) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(t, "", false) -} - -func (t *TeaserWidget) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &t, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *TeaserWidget) GetButton() *TeaserWidgetButton { - if o == nil { - return nil - } - return o.Button -} - -func (o *TeaserWidget) GetHeadline() *TeaserWidgetHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *TeaserWidget) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *TeaserWidget) GetImageURL() *string { - if o == nil { - return nil - } - return o.ImageURL -} - -func (o *TeaserWidget) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *TeaserWidget) GetSubHeadline() *TeaserWidgetSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *TeaserWidget) GetType() TeaserWidgetType { - if o == nil { - return TeaserWidgetType("") - } - return o.Type -} diff --git a/internal/sdk/models/shared/triggerportalflow.go b/internal/sdk/models/shared/triggerportalflow.go deleted file mode 100644 index fcc292c..0000000 --- a/internal/sdk/models/shared/triggerportalflow.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type FileConfig struct { - // Array of entity tags - Tags []string `json:"_tags,omitempty"` - // Indicate whether the file is shared with the end customer - SharedWithEndCustomer *bool `json:"shared_with_end_customer,omitempty"` -} - -func (o *FileConfig) GetTags() []string { - if o == nil { - return nil - } - return o.Tags -} - -func (o *FileConfig) GetSharedWithEndCustomer() *bool { - if o == nil { - return nil - } - return o.SharedWithEndCustomer -} - -type EcpConfig struct { - FileConfig *FileConfig `json:"file_config,omitempty"` -} - -func (o *EcpConfig) GetFileConfig() *FileConfig { - if o == nil { - return nil - } - return o.FileConfig -} - -type TriggerPortalFlow struct { - // Id of the activity - ActivityID *string `json:"activity_id,omitempty"` - EcpConfig *EcpConfig `json:"ecp_config,omitempty"` -} - -func (o *TriggerPortalFlow) GetActivityID() *string { - if o == nil { - return nil - } - return o.ActivityID -} - -func (o *TriggerPortalFlow) GetEcpConfig() *EcpConfig { - if o == nil { - return nil - } - return o.EcpConfig -} diff --git a/internal/sdk/models/shared/upsertportalconfig.go b/internal/sdk/models/shared/upsertportalconfig.go deleted file mode 100644 index 1a46ffa..0000000 --- a/internal/sdk/models/shared/upsertportalconfig.go +++ /dev/null @@ -1,923 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -type UpsertPortalConfigAdvancedMfa struct { - // Advanced MFA feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UpsertPortalConfigAdvancedMfa) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type UpsertPortalConfigEntryPoint string - -const ( - UpsertPortalConfigEntryPointPassword UpsertPortalConfigEntryPoint = "PASSWORD" - UpsertPortalConfigEntryPointSso UpsertPortalConfigEntryPoint = "SSO" -) - -func (e UpsertPortalConfigEntryPoint) ToPointer() *UpsertPortalConfigEntryPoint { - return &e -} -func (e *UpsertPortalConfigEntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = UpsertPortalConfigEntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigEntryPoint: %v", v) - } -} - -type UpsertPortalConfigPasswordlessLogin struct { - // Passwordless login feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UpsertPortalConfigPasswordlessLogin) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// UpsertPortalConfigAuthSettings - Authentication settings for the portal -type UpsertPortalConfigAuthSettings struct { - // Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. - AutoRedirectToSso *bool `json:"auto_redirect_to_sso,omitempty"` - EntryPoint *UpsertPortalConfigEntryPoint `json:"entry_point,omitempty"` - PasswordlessLogin *UpsertPortalConfigPasswordlessLogin `json:"passwordless_login,omitempty"` - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` -} - -func (o *UpsertPortalConfigAuthSettings) GetAutoRedirectToSso() *bool { - if o == nil { - return nil - } - return o.AutoRedirectToSso -} - -func (o *UpsertPortalConfigAuthSettings) GetEntryPoint() *UpsertPortalConfigEntryPoint { - if o == nil { - return nil - } - return o.EntryPoint -} - -func (o *UpsertPortalConfigAuthSettings) GetPasswordlessLogin() *UpsertPortalConfigPasswordlessLogin { - if o == nil { - return nil - } - return o.PasswordlessLogin -} - -func (o *UpsertPortalConfigAuthSettings) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -// UpsertPortalConfigPasswordPolicy - Password policy for the portal -type UpsertPortalConfigPasswordPolicy struct { - // Minimum password length - MinimumLength *int64 `json:"minimum_length,omitempty"` - // Require lowercase characters - RequireLowercase *bool `json:"require_lowercase,omitempty"` - // Require numbers - RequireNumbers *bool `json:"require_numbers,omitempty"` - // Require symbols - RequireSymbols *bool `json:"require_symbols,omitempty"` - // Require uppercase characters - RequireUppercase *bool `json:"require_uppercase,omitempty"` -} - -func (o *UpsertPortalConfigPasswordPolicy) GetMinimumLength() *int64 { - if o == nil { - return nil - } - return o.MinimumLength -} - -func (o *UpsertPortalConfigPasswordPolicy) GetRequireLowercase() *bool { - if o == nil { - return nil - } - return o.RequireLowercase -} - -func (o *UpsertPortalConfigPasswordPolicy) GetRequireNumbers() *bool { - if o == nil { - return nil - } - return o.RequireNumbers -} - -func (o *UpsertPortalConfigPasswordPolicy) GetRequireSymbols() *bool { - if o == nil { - return nil - } - return o.RequireSymbols -} - -func (o *UpsertPortalConfigPasswordPolicy) GetRequireUppercase() *bool { - if o == nil { - return nil - } - return o.RequireUppercase -} - -// UpsertPortalConfigCognitoDetails - AWS Cognito Pool details for the portal -type UpsertPortalConfigCognitoDetails struct { - // Cognito user pool ARN - CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` - // Cognito user pool client ID - CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` - // Cognito user pool ID - CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` - // Password policy for the portal - PasswordPolicy *UpsertPortalConfigPasswordPolicy `json:"password_policy,omitempty"` -} - -func (o *UpsertPortalConfigCognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolArn -} - -func (o *UpsertPortalConfigCognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolClientID -} - -func (o *UpsertPortalConfigCognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolID -} - -func (o *UpsertPortalConfigCognitoDetails) GetPasswordPolicy() *UpsertPortalConfigPasswordPolicy { - if o == nil { - return nil - } - return o.PasswordPolicy -} - -// UpsertPortalConfigContractSelectorConfig - Configuration for contract selector in the portal -type UpsertPortalConfigContractSelectorConfig struct { - // Whether to show inactive contracts in the selector - ShowInactive *bool `json:"show_inactive,omitempty"` - // Path to the property to use as the contract title - TitlePath *string `json:"title_path,omitempty"` -} - -func (o *UpsertPortalConfigContractSelectorConfig) GetShowInactive() *bool { - if o == nil { - return nil - } - return o.ShowInactive -} - -func (o *UpsertPortalConfigContractSelectorConfig) GetTitlePath() *string { - if o == nil { - return nil - } - return o.TitlePath -} - -// UpsertPortalConfigDefaultUserToNotify - Default 360 user to notify upon an internal notification -type UpsertPortalConfigDefaultUserToNotify struct { - // Default admin users for pending user notification to notify - OnPendingUser []AdminUser `json:"onPendingUser,omitempty"` -} - -func (o *UpsertPortalConfigDefaultUserToNotify) GetOnPendingUser() []AdminUser { - if o == nil { - return nil - } - return o.OnPendingUser -} - -type UpsertPortalConfigActionLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (o *UpsertPortalConfigActionLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *UpsertPortalConfigActionLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type UpsertPortalConfigEntityActions struct { - ActionLabel *UpsertPortalConfigActionLabel `json:"action_Label,omitempty"` - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *UpsertPortalConfigEntityActions) GetActionLabel() *UpsertPortalConfigActionLabel { - if o == nil { - return nil - } - return o.ActionLabel -} - -func (o *UpsertPortalConfigEntityActions) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *UpsertPortalConfigEntityActions) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type UpsertPortalConfigCadencePeriodType string - -const ( - UpsertPortalConfigCadencePeriodTypeDays UpsertPortalConfigCadencePeriodType = "days" - UpsertPortalConfigCadencePeriodTypeWeeks UpsertPortalConfigCadencePeriodType = "weeks" - UpsertPortalConfigCadencePeriodTypeMonths UpsertPortalConfigCadencePeriodType = "months" -) - -func (e UpsertPortalConfigCadencePeriodType) ToPointer() *UpsertPortalConfigCadencePeriodType { - return &e -} -func (e *UpsertPortalConfigCadencePeriodType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "days": - fallthrough - case "weeks": - fallthrough - case "months": - *e = UpsertPortalConfigCadencePeriodType(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigCadencePeriodType: %v", v) - } -} - -type UpsertPortalConfigRuleType string - -const ( - UpsertPortalConfigRuleTypeCadence UpsertPortalConfigRuleType = "cadence" - UpsertPortalConfigRuleTypeRelativeToCurrentValue UpsertPortalConfigRuleType = "relative_to_current_value" - UpsertPortalConfigRuleTypeDaysBeforeDate UpsertPortalConfigRuleType = "days_before_date" - UpsertPortalConfigRuleTypeOverduePayments UpsertPortalConfigRuleType = "overdue_payments" -) - -func (e UpsertPortalConfigRuleType) ToPointer() *UpsertPortalConfigRuleType { - return &e -} -func (e *UpsertPortalConfigRuleType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "cadence": - fallthrough - case "relative_to_current_value": - fallthrough - case "days_before_date": - fallthrough - case "overdue_payments": - *e = UpsertPortalConfigRuleType(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigRuleType: %v", v) - } -} - -type UpsertPortalConfigEntityEditRules struct { - AllowedDecrement *string `json:"allowed_decrement,omitempty"` - AllowedIncrement *string `json:"allowed_increment,omitempty"` - Attribute *string `json:"attribute,omitempty"` - CadencePeriod *float64 `json:"cadence_period,omitempty"` - CadencePeriodType *UpsertPortalConfigCadencePeriodType `json:"cadence_period_type,omitempty"` - ChangesAllowed *int64 `json:"changes_allowed,omitempty"` - GracePeriod *int64 `json:"grace_period,omitempty"` - NumberOfDaysBeforeRestriction *int64 `json:"number_of_days_before_restriction,omitempty"` - RuleType *UpsertPortalConfigRuleType `json:"rule_type,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *UpsertPortalConfigEntityEditRules) GetAllowedDecrement() *string { - if o == nil { - return nil - } - return o.AllowedDecrement -} - -func (o *UpsertPortalConfigEntityEditRules) GetAllowedIncrement() *string { - if o == nil { - return nil - } - return o.AllowedIncrement -} - -func (o *UpsertPortalConfigEntityEditRules) GetAttribute() *string { - if o == nil { - return nil - } - return o.Attribute -} - -func (o *UpsertPortalConfigEntityEditRules) GetCadencePeriod() *float64 { - if o == nil { - return nil - } - return o.CadencePeriod -} - -func (o *UpsertPortalConfigEntityEditRules) GetCadencePeriodType() *UpsertPortalConfigCadencePeriodType { - if o == nil { - return nil - } - return o.CadencePeriodType -} - -func (o *UpsertPortalConfigEntityEditRules) GetChangesAllowed() *int64 { - if o == nil { - return nil - } - return o.ChangesAllowed -} - -func (o *UpsertPortalConfigEntityEditRules) GetGracePeriod() *int64 { - if o == nil { - return nil - } - return o.GracePeriod -} - -func (o *UpsertPortalConfigEntityEditRules) GetNumberOfDaysBeforeRestriction() *int64 { - if o == nil { - return nil - } - return o.NumberOfDaysBeforeRestriction -} - -func (o *UpsertPortalConfigEntityEditRules) GetRuleType() *UpsertPortalConfigRuleType { - if o == nil { - return nil - } - return o.RuleType -} - -func (o *UpsertPortalConfigEntityEditRules) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type UpsertPortalConfigType struct { - // Attributes used to identify an entity - Attributes []string `json:"attributes,omitempty"` - // Enable/Disable the entity identifier - IsEnabled *bool `json:"isEnabled,omitempty"` -} - -func (o *UpsertPortalConfigType) GetAttributes() []string { - if o == nil { - return nil - } - return o.Attributes -} - -func (o *UpsertPortalConfigType) GetIsEnabled() *bool { - if o == nil { - return nil - } - return o.IsEnabled -} - -// UpsertPortalConfigEntityIdentifiers - Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type UpsertPortalConfigEntityIdentifiers struct { - Type *UpsertPortalConfigType `json:"type,omitempty"` -} - -func (o *UpsertPortalConfigEntityIdentifiers) GetType() *UpsertPortalConfigType { - if o == nil { - return nil - } - return o.Type -} - -// UpsertPortalConfigFeatureSettings - Feature settings for the portal -type UpsertPortalConfigFeatureSettings struct { - // Billing feature flag - Billing *bool `json:"billing,omitempty"` - // Change due date feature flag - ChangeDueDate *bool `json:"change_due_date,omitempty"` - // Enable or disable the new design for the portal - NewDesign *bool `json:"new_design,omitempty"` - // Start page feature flag - StartPage *bool `json:"start_page,omitempty"` -} - -func (o *UpsertPortalConfigFeatureSettings) GetBilling() *bool { - if o == nil { - return nil - } - return o.Billing -} - -func (o *UpsertPortalConfigFeatureSettings) GetChangeDueDate() *bool { - if o == nil { - return nil - } - return o.ChangeDueDate -} - -func (o *UpsertPortalConfigFeatureSettings) GetNewDesign() *bool { - if o == nil { - return nil - } - return o.NewDesign -} - -func (o *UpsertPortalConfigFeatureSettings) GetStartPage() *bool { - if o == nil { - return nil - } - return o.StartPage -} - -// UpsertPortalConfigImages - Teaser & Banner Image web links -type UpsertPortalConfigImages struct { - // URL of the order left teaser image - OrderLeftTeaser *string `json:"orderLeftTeaser,omitempty"` - // URL of the order right teaser image - OrderRightTeaser *string `json:"orderRightTeaser,omitempty"` - // URL of the welcome banner image - WelcomeBanner *string `json:"welcomeBanner,omitempty"` -} - -func (o *UpsertPortalConfigImages) GetOrderLeftTeaser() *string { - if o == nil { - return nil - } - return o.OrderLeftTeaser -} - -func (o *UpsertPortalConfigImages) GetOrderRightTeaser() *string { - if o == nil { - return nil - } - return o.OrderRightTeaser -} - -func (o *UpsertPortalConfigImages) GetWelcomeBanner() *string { - if o == nil { - return nil - } - return o.WelcomeBanner -} - -type UpsertPortalConfigSelfRegistrationSetting string - -const ( - UpsertPortalConfigSelfRegistrationSettingAllowWithContactCreation UpsertPortalConfigSelfRegistrationSetting = "ALLOW_WITH_CONTACT_CREATION" - UpsertPortalConfigSelfRegistrationSettingAllowWithoutContactCreation UpsertPortalConfigSelfRegistrationSetting = "ALLOW_WITHOUT_CONTACT_CREATION" - UpsertPortalConfigSelfRegistrationSettingDeny UpsertPortalConfigSelfRegistrationSetting = "DENY" -) - -func (e UpsertPortalConfigSelfRegistrationSetting) ToPointer() *UpsertPortalConfigSelfRegistrationSetting { - return &e -} -func (e *UpsertPortalConfigSelfRegistrationSetting) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ALLOW_WITH_CONTACT_CREATION": - fallthrough - case "ALLOW_WITHOUT_CONTACT_CREATION": - fallthrough - case "DENY": - *e = UpsertPortalConfigSelfRegistrationSetting(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigSelfRegistrationSetting: %v", v) - } -} - -type UpsertPortalConfigTriggerName string - -const ( - UpsertPortalConfigTriggerNameFirstLogin UpsertPortalConfigTriggerName = "FIRST_LOGIN" - UpsertPortalConfigTriggerNameAcceptOrder UpsertPortalConfigTriggerName = "ACCEPT_ORDER" - UpsertPortalConfigTriggerNameDeclineOrder UpsertPortalConfigTriggerName = "DECLINE_ORDER" -) - -func (e UpsertPortalConfigTriggerName) ToPointer() *UpsertPortalConfigTriggerName { - return &e -} -func (e *UpsertPortalConfigTriggerName) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "FIRST_LOGIN": - fallthrough - case "ACCEPT_ORDER": - fallthrough - case "DECLINE_ORDER": - *e = UpsertPortalConfigTriggerName(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigTriggerName: %v", v) - } -} - -type UpsertPortalConfigTriggeredJourneys struct { - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - TriggerName *UpsertPortalConfigTriggerName `json:"trigger_name,omitempty"` -} - -func (o *UpsertPortalConfigTriggeredJourneys) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *UpsertPortalConfigTriggeredJourneys) GetTriggerName() *UpsertPortalConfigTriggerName { - if o == nil { - return nil - } - return o.TriggerName -} - -type UpsertPortalConfig struct { - // Access token for the portal - AccessToken *string `json:"accessToken,omitempty"` - AdvancedMfa *UpsertPortalConfigAdvancedMfa `json:"advanced_mfa,omitempty"` - // Allowed file extensions for upload - AllowedFileExtensions *AllowedFileExtensions `json:"allowed_file_extensions,omitempty"` - ApprovalStateAttributes map[string][]string `json:"approval_state_attributes,omitempty"` - // Authentication settings for the portal - AuthSettings *UpsertPortalConfigAuthSettings `json:"auth_settings,omitempty"` - // AWS Cognito Pool details for the portal - CognitoDetails *UpsertPortalConfigCognitoDetails `json:"cognito_details,omitempty"` - // Stringified object with configuration details - Config *string `json:"config,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers []string `json:"contact_identifiers,omitempty"` - // Identifiers to identify a contract by a portal user. - ContractIdentifiers []ContractIdentifier `json:"contract_identifiers,omitempty"` - // Configuration for contract selector in the portal - ContractSelectorConfig *UpsertPortalConfigContractSelectorConfig `json:"contract_selector_config,omitempty"` - // Default 360 user to notify upon an internal notification - DefaultUserToNotify *UpsertPortalConfigDefaultUserToNotify `json:"default_user_to_notify,omitempty"` - // Entity ID - DesignID *string `json:"design_id,omitempty"` - // The URL on which the portal is accessible - Domain string `json:"domain"` - // Email templates used for authentication and internal processes - EmailTemplates *EmailTemplates `json:"email_templates,omitempty"` - // Enable/Disable the portal access - Enabled *bool `json:"enabled,omitempty"` - // Journey actions allowed on an entity by a portal user - EntityActions []UpsertPortalConfigEntityActions `json:"entity_actions,omitempty"` - // Rules for editing an entity by a portal user - EntityEditRules []UpsertPortalConfigEntityEditRules `json:"entity_edit_rules,omitempty"` - // Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - EntityIdentifiers *UpsertPortalConfigEntityIdentifiers `json:"entity_identifiers,omitempty"` - // Configured Portal extensions hooks - ExtensionHooks map[string]*ExtensionHookConfig `json:"extension_hooks,omitempty"` - // Configured Portal extensions - Extensions []ExtensionConfig `json:"extensions,omitempty"` - // Feature settings for the portal - FeatureSettings *UpsertPortalConfigFeatureSettings `json:"feature_settings,omitempty"` - // Teaser & Banner Image web links - Images *UpsertPortalConfigImages `json:"images,omitempty"` - // Number of years to look back for showing inactive contracts in the portal - InactiveContractCutoffYears *float64 `json:"inactive_contract_cutoff_years,omitempty"` - // Whether this is a dummy/test portal configuration - IsDummy *bool `json:"is_dummy,omitempty"` - // Mark true if the domain is an Epilot domain - IsEpilotDomain *bool `json:"is_epilot_domain,omitempty"` - // Whether this is a v3 portal configuration - IsV3Item *bool `json:"is_v3_item,omitempty"` - // Grace period in days for meter readings - MeterReadingGracePeriod *float64 `json:"meter_reading_grace_period,omitempty"` - // A short name to identify your portal - Name *string `json:"name,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` - Pages map[string]Page `json:"pages,omitempty"` - // ID of the portal - PortalID *string `json:"portal_id,omitempty"` - // Key of the portal config - PortalSkV3 *string `json:"portal_sk_v3,omitempty"` - // Prevent indexing by search engines - PreventSearchEngineIndexing *bool `json:"prevent_search_engine_indexing,omitempty"` - // Identifiers to identify a contact of a portal user during the registration. - RegistrationIdentifiers []ContractIdentifier `json:"registration_identifiers,omitempty"` - SelfRegistrationSetting *UpsertPortalConfigSelfRegistrationSetting `json:"self_registration_setting,omitempty"` - // Journeys automatically opened on a portal user action - TriggeredJourneys []UpsertPortalConfigTriggeredJourneys `json:"triggered_journeys,omitempty"` -} - -func (o *UpsertPortalConfig) GetAccessToken() *string { - if o == nil { - return nil - } - return o.AccessToken -} - -func (o *UpsertPortalConfig) GetAdvancedMfa() *UpsertPortalConfigAdvancedMfa { - if o == nil { - return nil - } - return o.AdvancedMfa -} - -func (o *UpsertPortalConfig) GetAllowedFileExtensions() *AllowedFileExtensions { - if o == nil { - return nil - } - return o.AllowedFileExtensions -} - -func (o *UpsertPortalConfig) GetApprovalStateAttributes() map[string][]string { - if o == nil { - return nil - } - return o.ApprovalStateAttributes -} - -func (o *UpsertPortalConfig) GetAuthSettings() *UpsertPortalConfigAuthSettings { - if o == nil { - return nil - } - return o.AuthSettings -} - -func (o *UpsertPortalConfig) GetCognitoDetails() *UpsertPortalConfigCognitoDetails { - if o == nil { - return nil - } - return o.CognitoDetails -} - -func (o *UpsertPortalConfig) GetConfig() *string { - if o == nil { - return nil - } - return o.Config -} - -func (o *UpsertPortalConfig) GetContactIdentifiers() []string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *UpsertPortalConfig) GetContractIdentifiers() []ContractIdentifier { - if o == nil { - return nil - } - return o.ContractIdentifiers -} - -func (o *UpsertPortalConfig) GetContractSelectorConfig() *UpsertPortalConfigContractSelectorConfig { - if o == nil { - return nil - } - return o.ContractSelectorConfig -} - -func (o *UpsertPortalConfig) GetDefaultUserToNotify() *UpsertPortalConfigDefaultUserToNotify { - if o == nil { - return nil - } - return o.DefaultUserToNotify -} - -func (o *UpsertPortalConfig) GetDesignID() *string { - if o == nil { - return nil - } - return o.DesignID -} - -func (o *UpsertPortalConfig) GetDomain() string { - if o == nil { - return "" - } - return o.Domain -} - -func (o *UpsertPortalConfig) GetEmailTemplates() *EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *UpsertPortalConfig) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *UpsertPortalConfig) GetEntityActions() []UpsertPortalConfigEntityActions { - if o == nil { - return nil - } - return o.EntityActions -} - -func (o *UpsertPortalConfig) GetEntityEditRules() []UpsertPortalConfigEntityEditRules { - if o == nil { - return nil - } - return o.EntityEditRules -} - -func (o *UpsertPortalConfig) GetEntityIdentifiers() *UpsertPortalConfigEntityIdentifiers { - if o == nil { - return nil - } - return o.EntityIdentifiers -} - -func (o *UpsertPortalConfig) GetExtensionHooks() map[string]*ExtensionHookConfig { - if o == nil { - return nil - } - return o.ExtensionHooks -} - -func (o *UpsertPortalConfig) GetExtensions() []ExtensionConfig { - if o == nil { - return nil - } - return o.Extensions -} - -func (o *UpsertPortalConfig) GetFeatureSettings() *UpsertPortalConfigFeatureSettings { - if o == nil { - return nil - } - return o.FeatureSettings -} - -func (o *UpsertPortalConfig) GetImages() *UpsertPortalConfigImages { - if o == nil { - return nil - } - return o.Images -} - -func (o *UpsertPortalConfig) GetInactiveContractCutoffYears() *float64 { - if o == nil { - return nil - } - return o.InactiveContractCutoffYears -} - -func (o *UpsertPortalConfig) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} - -func (o *UpsertPortalConfig) GetIsEpilotDomain() *bool { - if o == nil { - return nil - } - return o.IsEpilotDomain -} - -func (o *UpsertPortalConfig) GetIsV3Item() *bool { - if o == nil { - return nil - } - return o.IsV3Item -} - -func (o *UpsertPortalConfig) GetMeterReadingGracePeriod() *float64 { - if o == nil { - return nil - } - return o.MeterReadingGracePeriod -} - -func (o *UpsertPortalConfig) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *UpsertPortalConfig) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -func (o *UpsertPortalConfig) GetPages() map[string]Page { - if o == nil { - return nil - } - return o.Pages -} - -func (o *UpsertPortalConfig) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -func (o *UpsertPortalConfig) GetPortalSkV3() *string { - if o == nil { - return nil - } - return o.PortalSkV3 -} - -func (o *UpsertPortalConfig) GetPreventSearchEngineIndexing() *bool { - if o == nil { - return nil - } - return o.PreventSearchEngineIndexing -} - -func (o *UpsertPortalConfig) GetRegistrationIdentifiers() []ContractIdentifier { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} - -func (o *UpsertPortalConfig) GetSelfRegistrationSetting() *UpsertPortalConfigSelfRegistrationSetting { - if o == nil { - return nil - } - return o.SelfRegistrationSetting -} - -func (o *UpsertPortalConfig) GetTriggeredJourneys() []UpsertPortalConfigTriggeredJourneys { - if o == nil { - return nil - } - return o.TriggeredJourneys -} diff --git a/internal/sdk/models/shared/upsertportalconfigv3.go b/internal/sdk/models/shared/upsertportalconfigv3.go deleted file mode 100644 index 0bdfdfd..0000000 --- a/internal/sdk/models/shared/upsertportalconfigv3.go +++ /dev/null @@ -1,778 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" -) - -type UpsertPortalConfigV3AdvancedMfa struct { - // Advanced MFA feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UpsertPortalConfigV3AdvancedMfa) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -type UpsertPortalConfigV3EntryPoint string - -const ( - UpsertPortalConfigV3EntryPointPassword UpsertPortalConfigV3EntryPoint = "PASSWORD" - UpsertPortalConfigV3EntryPointSso UpsertPortalConfigV3EntryPoint = "SSO" -) - -func (e UpsertPortalConfigV3EntryPoint) ToPointer() *UpsertPortalConfigV3EntryPoint { - return &e -} -func (e *UpsertPortalConfigV3EntryPoint) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "PASSWORD": - fallthrough - case "SSO": - *e = UpsertPortalConfigV3EntryPoint(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigV3EntryPoint: %v", v) - } -} - -type UpsertPortalConfigV3PasswordlessLogin struct { - // Passwordless login feature flag - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UpsertPortalConfigV3PasswordlessLogin) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -// UpsertPortalConfigV3AuthSettings - Authentication settings for the portal -type UpsertPortalConfigV3AuthSettings struct { - // Decide whether to automatically redirect to the provider page during login, which would completely bypass showing the portal authentication page. - AutoRedirectToSso *bool `json:"auto_redirect_to_sso,omitempty"` - EntryPoint *UpsertPortalConfigV3EntryPoint `json:"entry_point,omitempty"` - PasswordlessLogin *UpsertPortalConfigV3PasswordlessLogin `json:"passwordless_login,omitempty"` - PreferredSsoProviders []string `json:"preferred_sso_providers,omitempty"` -} - -func (o *UpsertPortalConfigV3AuthSettings) GetAutoRedirectToSso() *bool { - if o == nil { - return nil - } - return o.AutoRedirectToSso -} - -func (o *UpsertPortalConfigV3AuthSettings) GetEntryPoint() *UpsertPortalConfigV3EntryPoint { - if o == nil { - return nil - } - return o.EntryPoint -} - -func (o *UpsertPortalConfigV3AuthSettings) GetPasswordlessLogin() *UpsertPortalConfigV3PasswordlessLogin { - if o == nil { - return nil - } - return o.PasswordlessLogin -} - -func (o *UpsertPortalConfigV3AuthSettings) GetPreferredSsoProviders() []string { - if o == nil { - return nil - } - return o.PreferredSsoProviders -} - -// UpsertPortalConfigV3PasswordPolicy - Password policy for the portal -type UpsertPortalConfigV3PasswordPolicy struct { - // Minimum password length - MinimumLength *int64 `json:"minimum_length,omitempty"` - // Require lowercase characters - RequireLowercase *bool `json:"require_lowercase,omitempty"` - // Require numbers - RequireNumbers *bool `json:"require_numbers,omitempty"` - // Require symbols - RequireSymbols *bool `json:"require_symbols,omitempty"` - // Require uppercase characters - RequireUppercase *bool `json:"require_uppercase,omitempty"` -} - -func (o *UpsertPortalConfigV3PasswordPolicy) GetMinimumLength() *int64 { - if o == nil { - return nil - } - return o.MinimumLength -} - -func (o *UpsertPortalConfigV3PasswordPolicy) GetRequireLowercase() *bool { - if o == nil { - return nil - } - return o.RequireLowercase -} - -func (o *UpsertPortalConfigV3PasswordPolicy) GetRequireNumbers() *bool { - if o == nil { - return nil - } - return o.RequireNumbers -} - -func (o *UpsertPortalConfigV3PasswordPolicy) GetRequireSymbols() *bool { - if o == nil { - return nil - } - return o.RequireSymbols -} - -func (o *UpsertPortalConfigV3PasswordPolicy) GetRequireUppercase() *bool { - if o == nil { - return nil - } - return o.RequireUppercase -} - -// UpsertPortalConfigV3CognitoDetails - AWS Cognito Pool details for the portal -type UpsertPortalConfigV3CognitoDetails struct { - // Cognito user pool ARN - CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` - // Cognito user pool client ID - CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` - // Cognito user pool ID - CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` - // Password policy for the portal - PasswordPolicy *UpsertPortalConfigV3PasswordPolicy `json:"password_policy,omitempty"` -} - -func (o *UpsertPortalConfigV3CognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolArn -} - -func (o *UpsertPortalConfigV3CognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolClientID -} - -func (o *UpsertPortalConfigV3CognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { - return nil - } - return o.CognitoUserPoolID -} - -func (o *UpsertPortalConfigV3CognitoDetails) GetPasswordPolicy() *UpsertPortalConfigV3PasswordPolicy { - if o == nil { - return nil - } - return o.PasswordPolicy -} - -// UpsertPortalConfigV3ContractSelectorConfig - Configuration for contract selector in the portal -type UpsertPortalConfigV3ContractSelectorConfig struct { - // Whether to show inactive contracts in the selector - ShowInactive *bool `json:"show_inactive,omitempty"` - // Path to the property to use as the contract title - TitlePath *string `json:"title_path,omitempty"` -} - -func (o *UpsertPortalConfigV3ContractSelectorConfig) GetShowInactive() *bool { - if o == nil { - return nil - } - return o.ShowInactive -} - -func (o *UpsertPortalConfigV3ContractSelectorConfig) GetTitlePath() *string { - if o == nil { - return nil - } - return o.TitlePath -} - -// UpsertPortalConfigV3DefaultUserToNotify - Default 360 user to notify upon an internal notification -type UpsertPortalConfigV3DefaultUserToNotify struct { - // Default admin users for pending user notification to notify - OnPendingUser []AdminUser `json:"onPendingUser,omitempty"` -} - -func (o *UpsertPortalConfigV3DefaultUserToNotify) GetOnPendingUser() []AdminUser { - if o == nil { - return nil - } - return o.OnPendingUser -} - -type UpsertPortalConfigV3ActionLabel struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (o *UpsertPortalConfigV3ActionLabel) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *UpsertPortalConfigV3ActionLabel) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type UpsertPortalConfigV3EntityActions struct { - ActionLabel *UpsertPortalConfigV3ActionLabel `json:"action_Label,omitempty"` - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - // URL-friendly identifier for the entity schema - Slug *EntitySlug `json:"slug,omitempty"` -} - -func (o *UpsertPortalConfigV3EntityActions) GetActionLabel() *UpsertPortalConfigV3ActionLabel { - if o == nil { - return nil - } - return o.ActionLabel -} - -func (o *UpsertPortalConfigV3EntityActions) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *UpsertPortalConfigV3EntityActions) GetSlug() *EntitySlug { - if o == nil { - return nil - } - return o.Slug -} - -type UpsertPortalConfigV3Type struct { - // Attributes used to identify an entity - Attributes []string `json:"attributes,omitempty"` - // Enable/Disable the entity identifier - IsEnabled *bool `json:"isEnabled,omitempty"` -} - -func (o *UpsertPortalConfigV3Type) GetAttributes() []string { - if o == nil { - return nil - } - return o.Attributes -} - -func (o *UpsertPortalConfigV3Type) GetIsEnabled() *bool { - if o == nil { - return nil - } - return o.IsEnabled -} - -// UpsertPortalConfigV3EntityIdentifiers - Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -type UpsertPortalConfigV3EntityIdentifiers struct { - Type *UpsertPortalConfigV3Type `json:"type,omitempty"` -} - -func (o *UpsertPortalConfigV3EntityIdentifiers) GetType() *UpsertPortalConfigV3Type { - if o == nil { - return nil - } - return o.Type -} - -// UpsertPortalConfigV3FeatureSettings - Feature settings for the portal -type UpsertPortalConfigV3FeatureSettings struct { - // Billing feature flag - Billing *bool `json:"billing,omitempty"` - // Change due date feature flag - ChangeDueDate *bool `json:"change_due_date,omitempty"` - // Enable or disable the new design for the portal - NewDesign *bool `json:"new_design,omitempty"` - // Start page feature flag - StartPage *bool `json:"start_page,omitempty"` -} - -func (o *UpsertPortalConfigV3FeatureSettings) GetBilling() *bool { - if o == nil { - return nil - } - return o.Billing -} - -func (o *UpsertPortalConfigV3FeatureSettings) GetChangeDueDate() *bool { - if o == nil { - return nil - } - return o.ChangeDueDate -} - -func (o *UpsertPortalConfigV3FeatureSettings) GetNewDesign() *bool { - if o == nil { - return nil - } - return o.NewDesign -} - -func (o *UpsertPortalConfigV3FeatureSettings) GetStartPage() *bool { - if o == nil { - return nil - } - return o.StartPage -} - -// UpsertPortalConfigV3Images - Teaser & Banner Image web links -type UpsertPortalConfigV3Images struct { - // URL of the order left teaser image - OrderLeftTeaser *string `json:"orderLeftTeaser,omitempty"` - // URL of the order right teaser image - OrderRightTeaser *string `json:"orderRightTeaser,omitempty"` - // URL of the welcome banner image - WelcomeBanner *string `json:"welcomeBanner,omitempty"` -} - -func (o *UpsertPortalConfigV3Images) GetOrderLeftTeaser() *string { - if o == nil { - return nil - } - return o.OrderLeftTeaser -} - -func (o *UpsertPortalConfigV3Images) GetOrderRightTeaser() *string { - if o == nil { - return nil - } - return o.OrderRightTeaser -} - -func (o *UpsertPortalConfigV3Images) GetWelcomeBanner() *string { - if o == nil { - return nil - } - return o.WelcomeBanner -} - -type UpsertPortalConfigV3SelfRegistrationSetting string - -const ( - UpsertPortalConfigV3SelfRegistrationSettingAllowWithContactCreation UpsertPortalConfigV3SelfRegistrationSetting = "ALLOW_WITH_CONTACT_CREATION" - UpsertPortalConfigV3SelfRegistrationSettingAllowWithoutContactCreation UpsertPortalConfigV3SelfRegistrationSetting = "ALLOW_WITHOUT_CONTACT_CREATION" - UpsertPortalConfigV3SelfRegistrationSettingDeny UpsertPortalConfigV3SelfRegistrationSetting = "DENY" -) - -func (e UpsertPortalConfigV3SelfRegistrationSetting) ToPointer() *UpsertPortalConfigV3SelfRegistrationSetting { - return &e -} -func (e *UpsertPortalConfigV3SelfRegistrationSetting) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ALLOW_WITH_CONTACT_CREATION": - fallthrough - case "ALLOW_WITHOUT_CONTACT_CREATION": - fallthrough - case "DENY": - *e = UpsertPortalConfigV3SelfRegistrationSetting(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigV3SelfRegistrationSetting: %v", v) - } -} - -type UpsertPortalConfigV3TriggerName string - -const ( - UpsertPortalConfigV3TriggerNameFirstLogin UpsertPortalConfigV3TriggerName = "FIRST_LOGIN" - UpsertPortalConfigV3TriggerNameAcceptOrder UpsertPortalConfigV3TriggerName = "ACCEPT_ORDER" - UpsertPortalConfigV3TriggerNameDeclineOrder UpsertPortalConfigV3TriggerName = "DECLINE_ORDER" -) - -func (e UpsertPortalConfigV3TriggerName) ToPointer() *UpsertPortalConfigV3TriggerName { - return &e -} -func (e *UpsertPortalConfigV3TriggerName) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "FIRST_LOGIN": - fallthrough - case "ACCEPT_ORDER": - fallthrough - case "DECLINE_ORDER": - *e = UpsertPortalConfigV3TriggerName(v) - return nil - default: - return fmt.Errorf("invalid value for UpsertPortalConfigV3TriggerName: %v", v) - } -} - -type UpsertPortalConfigV3TriggeredJourneys struct { - // Entity ID - JourneyID *string `json:"journey_id,omitempty"` - TriggerName *UpsertPortalConfigV3TriggerName `json:"trigger_name,omitempty"` -} - -func (o *UpsertPortalConfigV3TriggeredJourneys) GetJourneyID() *string { - if o == nil { - return nil - } - return o.JourneyID -} - -func (o *UpsertPortalConfigV3TriggeredJourneys) GetTriggerName() *UpsertPortalConfigV3TriggerName { - if o == nil { - return nil - } - return o.TriggerName -} - -type UpsertPortalConfigV3 struct { - // Access token for the portal - AccessToken *string `json:"accessToken,omitempty"` - AdvancedMfa *UpsertPortalConfigV3AdvancedMfa `json:"advanced_mfa,omitempty"` - // Allowed file extensions for upload - AllowedFileExtensions *AllowedFileExtensions `json:"allowed_file_extensions,omitempty"` - ApprovalStateAttributes any `json:"approval_state_attributes,omitempty"` - // Authentication settings for the portal - AuthSettings *UpsertPortalConfigV3AuthSettings `json:"auth_settings,omitempty"` - // AWS Cognito Pool details for the portal - CognitoDetails *UpsertPortalConfigV3CognitoDetails `json:"cognito_details,omitempty"` - // Stringified object with configuration details - Config *string `json:"config,omitempty"` - // Deprecated. Use registration_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - ContactIdentifiers []string `json:"contact_identifiers,omitempty"` - // Identifiers to identify a contract by a portal user. - ContractIdentifiers any `json:"contract_identifiers,omitempty"` - // Configuration for contract selector in the portal - ContractSelectorConfig *UpsertPortalConfigV3ContractSelectorConfig `json:"contract_selector_config,omitempty"` - // Default 360 user to notify upon an internal notification - DefaultUserToNotify *UpsertPortalConfigV3DefaultUserToNotify `json:"default_user_to_notify,omitempty"` - // Entity ID - DesignID *string `json:"design_id,omitempty"` - // The URL on which the portal is accessible - Domain *string `json:"domain,omitempty"` - // Email templates used for authentication and internal processes - EmailTemplates *EmailTemplates `json:"email_templates,omitempty"` - // Enable/Disable the portal access - Enabled *bool `json:"enabled,omitempty"` - // Journey actions allowed on an entity by a portal user - EntityActions []UpsertPortalConfigV3EntityActions `json:"entity_actions,omitempty"` - // Rules for editing an entity by a portal user - EntityEditRules any `json:"entity_edit_rules,omitempty"` - // Identifiers used to identify an entity by a portal user. Deprecated. Use contract_identifiers instead. - // - // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. - EntityIdentifiers *UpsertPortalConfigV3EntityIdentifiers `json:"entity_identifiers,omitempty"` - // Configured Portal extensions hooks - ExtensionHooks map[string]*ExtensionHookConfig `json:"extension_hooks,omitempty"` - // Configured Portal extensions - Extensions []ExtensionConfig `json:"extensions,omitempty"` - // Feature settings for the portal - FeatureSettings *UpsertPortalConfigV3FeatureSettings `json:"feature_settings,omitempty"` - // Teaser & Banner Image web links - Images *UpsertPortalConfigV3Images `json:"images,omitempty"` - // Number of years to look back for showing inactive contracts in the portal - InactiveContractCutoffYears *float64 `json:"inactive_contract_cutoff_years,omitempty"` - // Whether this is a dummy/test portal configuration - IsDummy *bool `json:"is_dummy,omitempty"` - // Mark true if the domain is an Epilot domain - IsEpilotDomain *bool `json:"is_epilot_domain,omitempty"` - // Whether this is a v3 portal configuration - IsV3Item *bool `json:"is_v3_item,omitempty"` - // Grace period in days for meter readings - MeterReadingGracePeriod *float64 `json:"meter_reading_grace_period,omitempty"` - // A short name to identify your portal - Name *string `json:"name,omitempty"` - // Origin of the portal - Origin *string `json:"origin,omitempty"` - Pages any `json:"pages,omitempty"` - // ID of the portal - PortalID *string `json:"portal_id,omitempty"` - // Key of the portal config - PortalSkV3 *string `json:"portal_sk_v3,omitempty"` - // Prevent indexing by search engines - PreventSearchEngineIndexing *bool `json:"prevent_search_engine_indexing,omitempty"` - // Identifiers to identify a contact of a portal user during the registration. - RegistrationIdentifiers any `json:"registration_identifiers,omitempty"` - SelfRegistrationSetting *UpsertPortalConfigV3SelfRegistrationSetting `json:"self_registration_setting,omitempty"` - // Journeys automatically opened on a portal user action - TriggeredJourneys []UpsertPortalConfigV3TriggeredJourneys `json:"triggered_journeys,omitempty"` -} - -func (o *UpsertPortalConfigV3) GetAccessToken() *string { - if o == nil { - return nil - } - return o.AccessToken -} - -func (o *UpsertPortalConfigV3) GetAdvancedMfa() *UpsertPortalConfigV3AdvancedMfa { - if o == nil { - return nil - } - return o.AdvancedMfa -} - -func (o *UpsertPortalConfigV3) GetAllowedFileExtensions() *AllowedFileExtensions { - if o == nil { - return nil - } - return o.AllowedFileExtensions -} - -func (o *UpsertPortalConfigV3) GetApprovalStateAttributes() any { - if o == nil { - return nil - } - return o.ApprovalStateAttributes -} - -func (o *UpsertPortalConfigV3) GetAuthSettings() *UpsertPortalConfigV3AuthSettings { - if o == nil { - return nil - } - return o.AuthSettings -} - -func (o *UpsertPortalConfigV3) GetCognitoDetails() *UpsertPortalConfigV3CognitoDetails { - if o == nil { - return nil - } - return o.CognitoDetails -} - -func (o *UpsertPortalConfigV3) GetConfig() *string { - if o == nil { - return nil - } - return o.Config -} - -func (o *UpsertPortalConfigV3) GetContactIdentifiers() []string { - if o == nil { - return nil - } - return o.ContactIdentifiers -} - -func (o *UpsertPortalConfigV3) GetContractIdentifiers() any { - if o == nil { - return nil - } - return o.ContractIdentifiers -} - -func (o *UpsertPortalConfigV3) GetContractSelectorConfig() *UpsertPortalConfigV3ContractSelectorConfig { - if o == nil { - return nil - } - return o.ContractSelectorConfig -} - -func (o *UpsertPortalConfigV3) GetDefaultUserToNotify() *UpsertPortalConfigV3DefaultUserToNotify { - if o == nil { - return nil - } - return o.DefaultUserToNotify -} - -func (o *UpsertPortalConfigV3) GetDesignID() *string { - if o == nil { - return nil - } - return o.DesignID -} - -func (o *UpsertPortalConfigV3) GetDomain() *string { - if o == nil { - return nil - } - return o.Domain -} - -func (o *UpsertPortalConfigV3) GetEmailTemplates() *EmailTemplates { - if o == nil { - return nil - } - return o.EmailTemplates -} - -func (o *UpsertPortalConfigV3) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *UpsertPortalConfigV3) GetEntityActions() []UpsertPortalConfigV3EntityActions { - if o == nil { - return nil - } - return o.EntityActions -} - -func (o *UpsertPortalConfigV3) GetEntityEditRules() any { - if o == nil { - return nil - } - return o.EntityEditRules -} - -func (o *UpsertPortalConfigV3) GetEntityIdentifiers() *UpsertPortalConfigV3EntityIdentifiers { - if o == nil { - return nil - } - return o.EntityIdentifiers -} - -func (o *UpsertPortalConfigV3) GetExtensionHooks() map[string]*ExtensionHookConfig { - if o == nil { - return nil - } - return o.ExtensionHooks -} - -func (o *UpsertPortalConfigV3) GetExtensions() []ExtensionConfig { - if o == nil { - return nil - } - return o.Extensions -} - -func (o *UpsertPortalConfigV3) GetFeatureSettings() *UpsertPortalConfigV3FeatureSettings { - if o == nil { - return nil - } - return o.FeatureSettings -} - -func (o *UpsertPortalConfigV3) GetImages() *UpsertPortalConfigV3Images { - if o == nil { - return nil - } - return o.Images -} - -func (o *UpsertPortalConfigV3) GetInactiveContractCutoffYears() *float64 { - if o == nil { - return nil - } - return o.InactiveContractCutoffYears -} - -func (o *UpsertPortalConfigV3) GetIsDummy() *bool { - if o == nil { - return nil - } - return o.IsDummy -} - -func (o *UpsertPortalConfigV3) GetIsEpilotDomain() *bool { - if o == nil { - return nil - } - return o.IsEpilotDomain -} - -func (o *UpsertPortalConfigV3) GetIsV3Item() *bool { - if o == nil { - return nil - } - return o.IsV3Item -} - -func (o *UpsertPortalConfigV3) GetMeterReadingGracePeriod() *float64 { - if o == nil { - return nil - } - return o.MeterReadingGracePeriod -} - -func (o *UpsertPortalConfigV3) GetName() *string { - if o == nil { - return nil - } - return o.Name -} - -func (o *UpsertPortalConfigV3) GetOrigin() *string { - if o == nil { - return nil - } - return o.Origin -} - -func (o *UpsertPortalConfigV3) GetPages() any { - if o == nil { - return nil - } - return o.Pages -} - -func (o *UpsertPortalConfigV3) GetPortalID() *string { - if o == nil { - return nil - } - return o.PortalID -} - -func (o *UpsertPortalConfigV3) GetPortalSkV3() *string { - if o == nil { - return nil - } - return o.PortalSkV3 -} - -func (o *UpsertPortalConfigV3) GetPreventSearchEngineIndexing() *bool { - if o == nil { - return nil - } - return o.PreventSearchEngineIndexing -} - -func (o *UpsertPortalConfigV3) GetRegistrationIdentifiers() any { - if o == nil { - return nil - } - return o.RegistrationIdentifiers -} - -func (o *UpsertPortalConfigV3) GetSelfRegistrationSetting() *UpsertPortalConfigV3SelfRegistrationSetting { - if o == nil { - return nil - } - return o.SelfRegistrationSetting -} - -func (o *UpsertPortalConfigV3) GetTriggeredJourneys() []UpsertPortalConfigV3TriggeredJourneys { - if o == nil { - return nil - } - return o.TriggeredJourneys -} diff --git a/internal/sdk/models/shared/upsertportalwidget.go b/internal/sdk/models/shared/upsertportalwidget.go deleted file mode 100644 index 60e9c8a..0000000 --- a/internal/sdk/models/shared/upsertportalwidget.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -type UpsertPortalWidget struct { - Widgets []any `json:"widgets"` -} - -func (o *UpsertPortalWidget) GetWidgets() []any { - if o == nil { - return []any{} - } - return o.Widgets -} diff --git a/internal/sdk/models/shared/userrole.go b/internal/sdk/models/shared/userrole.go new file mode 100644 index 0000000..ac997ce --- /dev/null +++ b/internal/sdk/models/shared/userrole.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package shared + +import ( + "encoding/json" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "time" +) + +type UserRoleType string + +const ( + UserRoleTypeUserRole UserRoleType = "user_role" +) + +func (e UserRoleType) ToPointer() *UserRoleType { + return &e +} +func (e *UserRoleType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "user_role": + *e = UserRoleType(v) + return nil + default: + return fmt.Errorf("invalid value for UserRoleType: %v", v) + } +} + +// UserRole - A standard user role. Must be explicitly assigned to users. +type UserRole struct { + // date and time then the role will expire + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // List of grants (permissions) applied to the role + Grants []Grant `json:"grants"` + // Format: : + ID string `json:"id"` + // Human-friendly name for the role + Name string `json:"name"` + // Id of an organization + OrganizationID string `json:"organization_id"` + // URL-friendly name for the role + Slug string `json:"slug"` + Type UserRoleType `json:"type"` +} + +func (u UserRole) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UserRole) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"grants", "id", "name", "organization_id", "slug", "type"}); err != nil { + return err + } + return nil +} + +func (u *UserRole) GetExpiresAt() *time.Time { + if u == nil { + return nil + } + return u.ExpiresAt +} + +func (u *UserRole) GetGrants() []Grant { + if u == nil { + return []Grant{} + } + return u.Grants +} + +func (u *UserRole) GetID() string { + if u == nil { + return "" + } + return u.ID +} + +func (u *UserRole) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *UserRole) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UserRole) GetSlug() string { + if u == nil { + return "" + } + return u.Slug +} + +func (u *UserRole) GetType() UserRoleType { + if u == nil { + return UserRoleType("") + } + return u.Type +} diff --git a/internal/sdk/models/shared/widgetaction.go b/internal/sdk/models/shared/widgetaction.go deleted file mode 100644 index 75ba010..0000000 --- a/internal/sdk/models/shared/widgetaction.go +++ /dev/null @@ -1,157 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type Label struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (l Label) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(l, "", false) -} - -func (l *Label) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *Label) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *Label) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type WidgetActionRules struct { - Attribute string `json:"attribute"` - AttributeValue string `json:"attribute_value"` - Entity string `json:"entity"` -} - -func (w WidgetActionRules) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(w, "", false) -} - -func (w *WidgetActionRules) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &w, "", false, []string{"attribute", "attribute_value", "entity"}); err != nil { - return err - } - return nil -} - -func (o *WidgetActionRules) GetAttribute() string { - if o == nil { - return "" - } - return o.Attribute -} - -func (o *WidgetActionRules) GetAttributeValue() string { - if o == nil { - return "" - } - return o.AttributeValue -} - -func (o *WidgetActionRules) GetEntity() string { - if o == nil { - return "" - } - return o.Entity -} - -type WidgetActionType string - -const ( - WidgetActionTypeLink WidgetActionType = "link" - WidgetActionTypeJourney WidgetActionType = "journey" -) - -func (e WidgetActionType) ToPointer() *WidgetActionType { - return &e -} -func (e *WidgetActionType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "link": - fallthrough - case "journey": - *e = WidgetActionType(v) - return nil - default: - return fmt.Errorf("invalid value for WidgetActionType: %v", v) - } -} - -type WidgetAction struct { - ID string `json:"_id"` - Label Label `json:"label"` - Rules []WidgetActionRules `json:"rules,omitempty"` - Type WidgetActionType `json:"type"` - URL string `json:"url"` -} - -func (w WidgetAction) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(w, "", false) -} - -func (w *WidgetAction) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &w, "", false, []string{"_id", "label", "type", "url"}); err != nil { - return err - } - return nil -} - -func (o *WidgetAction) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *WidgetAction) GetLabel() Label { - if o == nil { - return Label{} - } - return o.Label -} - -func (o *WidgetAction) GetRules() []WidgetActionRules { - if o == nil { - return nil - } - return o.Rules -} - -func (o *WidgetAction) GetType() WidgetActionType { - if o == nil { - return WidgetActionType("") - } - return o.Type -} - -func (o *WidgetAction) GetURL() string { - if o == nil { - return "" - } - return o.URL -} diff --git a/internal/sdk/models/shared/widgetbase.go b/internal/sdk/models/shared/widgetbase.go deleted file mode 100644 index 9af4cc3..0000000 --- a/internal/sdk/models/shared/widgetbase.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package shared - -import ( - "encoding/json" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" -) - -type WidgetBaseHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (w WidgetBaseHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(w, "", false) -} - -func (w *WidgetBaseHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &w, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *WidgetBaseHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *WidgetBaseHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type WidgetBaseSubHeadline struct { - De *string `json:"de,omitempty"` - En *string `json:"en,omitempty"` -} - -func (w WidgetBaseSubHeadline) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(w, "", false) -} - -func (w *WidgetBaseSubHeadline) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &w, "", false, nil); err != nil { - return err - } - return nil -} - -func (o *WidgetBaseSubHeadline) GetDe() *string { - if o == nil { - return nil - } - return o.De -} - -func (o *WidgetBaseSubHeadline) GetEn() *string { - if o == nil { - return nil - } - return o.En -} - -type WidgetBaseType string - -const ( - WidgetBaseTypeActionWidget WidgetBaseType = "ACTION_WIDGET" - WidgetBaseTypeContentWidget WidgetBaseType = "CONTENT_WIDGET" - WidgetBaseTypeEntityWidget WidgetBaseType = "ENTITY_WIDGET" - WidgetBaseTypeTeaserWidget WidgetBaseType = "TEASER_WIDGET" - WidgetBaseTypeDocumentWidget WidgetBaseType = "DOCUMENT_WIDGET" - WidgetBaseTypePaymentWidget WidgetBaseType = "PAYMENT_WIDGET" - WidgetBaseTypeMeterReadingWidget WidgetBaseType = "METER_READING_WIDGET" - WidgetBaseTypeMeterChartWidget WidgetBaseType = "METER_CHART_WIDGET" - WidgetBaseTypeCampaignWidget WidgetBaseType = "CAMPAIGN_WIDGET" -) - -func (e WidgetBaseType) ToPointer() *WidgetBaseType { - return &e -} -func (e *WidgetBaseType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "ACTION_WIDGET": - fallthrough - case "CONTENT_WIDGET": - fallthrough - case "ENTITY_WIDGET": - fallthrough - case "TEASER_WIDGET": - fallthrough - case "DOCUMENT_WIDGET": - fallthrough - case "PAYMENT_WIDGET": - fallthrough - case "METER_READING_WIDGET": - fallthrough - case "METER_CHART_WIDGET": - fallthrough - case "CAMPAIGN_WIDGET": - *e = WidgetBaseType(v) - return nil - default: - return fmt.Errorf("invalid value for WidgetBaseType: %v", v) - } -} - -type WidgetBase struct { - Headline *WidgetBaseHeadline `json:"headline,omitempty"` - ID string `json:"id"` - // Index of the widget in the list, used for ordering (left or right) - ListIndex int64 `json:"listIndex"` - SubHeadline *WidgetBaseSubHeadline `json:"subHeadline,omitempty"` - Type WidgetBaseType `json:"type"` -} - -func (w WidgetBase) MarshalJSON() ([]byte, error) { - return utils.MarshalJSON(w, "", false) -} - -func (w *WidgetBase) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &w, "", false, []string{"id", "listIndex", "type"}); err != nil { - return err - } - return nil -} - -func (o *WidgetBase) GetHeadline() *WidgetBaseHeadline { - if o == nil { - return nil - } - return o.Headline -} - -func (o *WidgetBase) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *WidgetBase) GetListIndex() int64 { - if o == nil { - return 0 - } - return o.ListIndex -} - -func (o *WidgetBase) GetSubHeadline() *WidgetBaseSubHeadline { - if o == nil { - return nil - } - return o.SubHeadline -} - -func (o *WidgetBase) GetType() WidgetBaseType { - if o == nil { - return WidgetBaseType("") - } - return o.Type -} diff --git a/internal/sdk/optionalnullable/optionalnullable.go b/internal/sdk/optionalnullable/optionalnullable.go new file mode 100644 index 0000000..c6739be --- /dev/null +++ b/internal/sdk/optionalnullable/optionalnullable.go @@ -0,0 +1,233 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "bytes" + "encoding/json" + "reflect" +) + +// OptionalNullable represents a field that can distinguish between three states: +// 1. Set to a value: field is present with a non-nil value +// 2. Set to nil: field is present but explicitly set to null in JSON +// 3. Unset: field is omitted from JSON entirely +// +// This type is designed to work with JSON marshaling/unmarshaling and supports +// the `omitempty` struct tag to properly omit unset fields from JSON output. +// +// Usage: +// +// type User struct { +// Name OptionalNullable[string] `json:"name,omitempty"` +// Age OptionalNullable[int] `json:"age,omitempty"` +// Tags OptionalNullable[[]string] `json:"tags,omitempty"` +// } +// +// // Set to value +// name := "John" +// user.Name = From(&name) +// +// // Set to nil (will appear as "name": null in JSON) +// user.Name = From[string](nil) +// +// // Leave unset (will be omitted from JSON with omitempty) +// user := User{} +// +// WARNING: Do NOT use *OptionalNullable[T] as a field type. Always use OptionalNullable[T] directly. +// Using *OptionalNullable[T] will break the omitempty behavior and JSON marshaling. +// +// The type is implemented as a map[bool]*T where: +// - nil map represents unset state +// - Map with true key represents set state (value may be nil) +type OptionalNullable[T any] map[bool]*T + +// From creates a new OptionalNullable with the given value. +// Pass nil to create a OptionalNullable that is set to null. +// Pass a pointer to a value to create a OptionalNullable with that value. +// +// Examples: +// +// hello := "hello" +// From(&hello) // set to "hello" +// From[string](nil) // set to null +func From[T any](value *T) OptionalNullable[T] { + return map[bool]*T{ + true: value, + } +} + +// IsNull returns true if the OptionalNullable is explicitly set to nil. +// Returns false if the OptionalNullable is unset or has a value. +// +// Note: This differs from traditional null checks because unset fields +// return false, not true. Use IsSet() to check if a field was provided. +func (n OptionalNullable[T]) IsNull() bool { + v, ok := n[true] + return ok && v == nil +} + +// IsSet returns true if the OptionalNullable has been explicitly set (to either a value or nil). +// Returns false if the OptionalNullable is unset (omitted from JSON). +// +// This is the key method for distinguishing between: +// - Set to nil: IsSet() = true, IsNull() = true +// - Unset: IsSet() = false, IsNull() = false +func (n OptionalNullable[T]) IsSet() bool { + _, ok := n[true] + return ok +} + +// Get returns the internal pointer and whether the field was set. +// +// Return values: +// - (ptr, true): field was set (ptr may be nil if set to null) +// - (nil, false): field was unset/omitted +// +// This method provides direct access to the internal pointer representation. +func (n OptionalNullable[T]) Get() (*T, bool) { + v, ok := n[true] + return v, ok +} + +// GetOrZero returns the value and whether it was set. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (zero, true): field was explicitly set to nil +// - (zero, false): field was unset/omitted +// +// Examples: +// +// val, ok := nullable.GetOrZero() +// if !ok { +// // Field was unset/omitted +// } else if nullable.IsNull() { +// // Field was explicitly set to null +// } else { +// // Field has a value: val +// } +func (n OptionalNullable[T]) GetOrZero() (T, bool) { + var zero T + + if v, ok := n[true]; ok { + if v == nil { + return zero, true + } + return *v, true + } + return zero, false +} + +// GetUntyped returns the value as interface{} and whether it was set. +// This is useful for reflection-based code that needs to work with the value +// without knowing the specific type T. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (nil, true): field was explicitly set to nil +// - (nil, false): field was unset/omitted +func (n OptionalNullable[T]) GetUntyped() (interface{}, bool) { + if v, ok := n[true]; ok { + if v == nil { + return nil, true + } + return *v, true + } + return nil, false +} + +// Set sets the OptionalNullable to the given value pointer. +// Pass nil to set the field to null. +// Pass a pointer to a value to set the field to that value. +// +// Examples: +// +// nullable.Set(ptrFrom("hello")) // set to "hello" +// nullable.Set(nil) // set to null +func (n *OptionalNullable[T]) Set(value *T) { + *n = map[bool]*T{ + true: value, + } +} + +// Unset removes the value, making the field unset/omitted. +// After calling Unset(), IsSet() will return false and the field +// will be omitted from JSON output when using omitempty. +func (n *OptionalNullable[T]) Unset() { + *n = map[bool]*T{} +} + +// MarshalJSON implements json.Marshaler. +// +// Behavior: +// - Unset fields: omitted from JSON when struct field has omitempty tag +// - Null fields: serialized as "null" +// - Value fields: serialized as the actual value +// +// The omitempty behavior works because an empty map is considered +// a zero value by Go's JSON package. +func (n OptionalNullable[T]) MarshalJSON() ([]byte, error) { + if n.IsNull() { + return []byte("null"), nil + } + + return json.Marshal(n[true]) +} + +// UnmarshalJSON implements json.Unmarshaler. +// +// Behavior: +// - "null" in JSON: sets the field to null (IsSet=true, IsNull=true) +// - Any other value: sets the field to that value (IsSet=true, IsNull=false) +// - Missing from JSON: field remains unset (IsSet=false, IsNull=false) +func (n *OptionalNullable[T]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, []byte("null")) { + n.Set(nil) + return nil + } + var v T + if err := json.Unmarshal(data, &v); err != nil { + return err + } + n.Set(&v) + return nil +} + +// NullableInterface defines the interface that all OptionalNullable[T] types implement. +// This interface provides untyped access to optional nullable values for reflection-based code. +type OptionalNullableInterface interface { + GetUntyped() (interface{}, bool) +} + +// AsOptionalNullable attempts to convert a reflect.Value to a OptionalNullableInterface. +// This is a helper function for reflection-based code that needs to check +// if a value implements the optional nullable interface pattern. +// +// Returns: +// - (nullable, true): if the value implements OptionalNullableInterface +// - (nil, false): if the value does not implement OptionalNullableInterface +// +// Example usage: +// +// if nullable, ok := AsOptionalNullable(reflectValue); ok { +// if value, isSet := nullable.GetUntyped(); isSet { +// // Handle the nullable value +// } +// } +func AsOptionalNullable(v reflect.Value) (OptionalNullableInterface, bool) { + // Check if the value can be converted to an interface first + if !v.CanInterface() { + return nil, false + } + + // Check if the underlying value is a nil map (unset nullable) + if v.Kind() == reflect.Map && v.IsNil() { + return nil, false + } + + if nullable, ok := v.Interface().(OptionalNullableInterface); ok { + return nullable, true + } + return nil, false +} diff --git a/internal/sdk/optionalnullable/optionalnullable_test.go b/internal/sdk/optionalnullable/optionalnullable_test.go new file mode 100644 index 0000000..e6e5a01 --- /dev/null +++ b/internal/sdk/optionalnullable/optionalnullable_test.go @@ -0,0 +1,1806 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "encoding/json" + "reflect" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// Test helper function to create pointers from values +func ptrFrom[T any](value T) *T { + return &value +} + +// Test helper types for comprehensive testing +type TestStruct struct { + Name string `json:"name"` + Age int `json:"age"` +} + +type TestContainer struct { + StringField OptionalNullable[string] `json:"string_field,omitempty"` + IntField OptionalNullable[int] `json:"int_field,omitempty"` + SliceField OptionalNullable[[]string] `json:"slice_field,omitempty"` + StructField OptionalNullable[TestStruct] `json:"struct_field,omitempty"` +} + +// TestNewNullable tests the From constructor +func TestNewNullable(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("with int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("with empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("with struct value", func(t *testing.T) { + t.Parallel() + val := TestStruct{Name: "John", Age: 30} + nullable := From(&val) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + v, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, val, v) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) +} + +// TestNewNullableUnset tests the NewNullableUnset constructor +func TestNewNullableUnset(t *testing.T) { + t.Parallel() + t.Run("string type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("int type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, got) // zero value for int + }) + + t.Run("slice type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestIsNull tests the IsNull method +func TestIsNull(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.False(t, nullable.IsNull()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsNull()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsNull()) + }) +} + +// TestIsSet tests the IsSet method +func TestIsSet(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.True(t, nullable.IsSet()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsSet()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsSet()) + }) +} + +// TestGet tests the Get method +func TestGet(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b"})) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("with nil slice pointer", func(t *testing.T) { + t.Parallel() + nullable := From[[]string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestPointer tests the Pointer method +func TestPointer(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, ptr) + assert.Equal(t, "test", *ptr) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.Nil(t, ptr) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + ptr, ok := nullable.Get() + assert.False(t, ok) + assert.Nil(t, ptr) + }) +} + +// TestSet tests the Set method +func TestSet(t *testing.T) { + t.Parallel() + t.Run("set string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + // Set a value + nullable.Set(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("set int value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[int]{} + + nullable.Set(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("set slice value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{"a", "b"} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("set empty slice", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("overwrite existing value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("original")) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", got) + + // Set new value + nullable.Set(ptrFrom("new")) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "new", got) + }) +} + +// TestUnset tests the Unset method +func TestUnset(t *testing.T) { + t.Parallel() + t.Run("unset from value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + // Initially set + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + // Value is now internal to the map implementation + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset from nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + // Initially set to nil + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) // Set to nil should be null + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + }) + + t.Run("unset already unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Unset again + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Empty map is not null + }) +} + +// TestMarshalJSON tests JSON marshaling +func TestMarshalJSON(t *testing.T) { + t.Parallel() + t.Run("marshal string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"test"`, string(data)) + }) + + t.Run("marshal int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `42`, string(data)) + }) + + t.Run("marshal nil value", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("marshal slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `["a","b","c"]`, string(data)) + }) + + t.Run("marshal empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `[]`, string(data)) + }) + + t.Run("marshal struct value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(TestStruct{Name: "John", Age: 30})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `{"name":"John","age":30}`, string(data)) + }) + + // Note: Unset values are not tested here because the current implementation + // doesn't handle unset fields in marshaling (see TODO in the code) +} + +// TestUnmarshalJSON tests JSON unmarshaling +func TestUnmarshalJSON(t *testing.T) { + t.Parallel() + t.Run("unmarshal string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`"test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("unmarshal int value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`42`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("unmarshal null value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unmarshal slice value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`["a","b","c"]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("unmarshal empty slice", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`[]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("unmarshal struct value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{"name":"John","age":30}`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) + + t.Run("unmarshal invalid JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`invalid`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal invalid JSON for int", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`"not_a_number"`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal malformed JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{invalid json`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) +} + +// TestJSONRoundTrip tests marshaling and unmarshaling together +func TestJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom("test value")) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("nil value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From[string](nil) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("slice round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom([]string{"a", "b", "c"})) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[[]string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) +} + +// TestJSONToJSONRoundTrip tests starting with JSON and ensuring we can serialize back to the same JSON +func TestJSONToJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `"hello world"` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello world", got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("null value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `null` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("int value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `42` + + // Unmarshal from JSON + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("slice value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `["a","b","c"]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("empty slice JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `[]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("struct value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `{"name":"Alice","age":25}` + + // Unmarshal from JSON + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Alice", Age: 25}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) +} + +// TestContainerStates tests comprehensive state detection and serialization with TestContainer +func TestContainerStates(t *testing.T) { + t.Parallel() + t.Run("all fields set to values", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), + IntField: From(ptrFrom(42)), + SliceField: From(ptrFrom([]string{"a", "b"})), + StructField: From(ptrFrom(TestStruct{Name: "John", Age: 30})), + } + + // Verify all fields are set and not null + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello", stringVal) + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, intVal) + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, sliceVal) + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, structVal) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Equal(t, float64(42), result["int_field"]) // JSON numbers are float64 + assert.Equal(t, []interface{}{"a", "b"}, result["slice_field"]) + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "John", structResult["name"]) + assert.Equal(t, float64(30), structResult["age"]) + }) + + t.Run("all fields set to nil", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From[string](nil), + IntField: From[int](nil), + SliceField: From[[]string](nil), + StructField: From[TestStruct](nil), + } + + // Verify all fields are set but null + assert.True(t, container.StringField.IsSet()) + assert.True(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.True(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.True(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for nil values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) // set to nil still returns true + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, sliceVal) // zero value for slice is nil + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - all should be null + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Nil(t, result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.Nil(t, result["slice_field"]) + assert.Nil(t, result["struct_field"]) + }) + + t.Run("all fields unset", func(t *testing.T) { + t.Parallel() + container := TestContainer{} + + // Verify all fields are unset + assert.False(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) // unset is not null in new implementation + assert.False(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.False(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for unset values + stringVal, ok := container.StringField.GetOrZero() + assert.False(t, ok) // unset returns false + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) // zero value + + structVal, ok := container.StructField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - unset fields should be omitted due to omitempty + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // With omitempty, unset fields should not appear in JSON + assert.NotContains(t, result, "string_field") + assert.NotContains(t, result, "int_field") + assert.NotContains(t, result, "slice_field") + assert.NotContains(t, result, "struct_field") + }) + + t.Run("slice field states: nil vs unset vs empty vs set", func(t *testing.T) { + t.Parallel() + // Test all possible slice states + nilSlice := TestContainer{ + SliceField: From[[]string](nil), // explicitly set to nil + } + unsetSlice := TestContainer{} // unset + emptySlice := TestContainer{ + SliceField: From(ptrFrom([]string{})), // empty slice + } + setSlice := TestContainer{ + SliceField: From(ptrFrom([]string{"a", "b"})), // slice with values + } + + // Verify nil slice + assert.True(t, nilSlice.SliceField.IsSet()) + assert.True(t, nilSlice.SliceField.IsNull()) + val, ok := nilSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, val) + + // Verify unset slice + assert.False(t, unsetSlice.SliceField.IsSet()) + assert.False(t, unsetSlice.SliceField.IsNull()) // Unset is not null + val, ok = unsetSlice.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, val) + + // Verify empty slice + assert.True(t, emptySlice.SliceField.IsSet()) + assert.False(t, emptySlice.SliceField.IsNull()) + val, ok = emptySlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, val) + + // Verify set slice + assert.True(t, setSlice.SliceField.IsSet()) + assert.False(t, setSlice.SliceField.IsNull()) + val, ok = setSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, val) + + // Test JSON serialization for each state + nilData, err := json.Marshal(nilSlice) + require.NoError(t, err) + assert.Contains(t, string(nilData), `"slice_field":null`) + + unsetData, err := json.Marshal(unsetSlice) + require.NoError(t, err) + assert.NotContains(t, string(unsetData), "slice_field") // omitted due to omitempty + + emptyData, err := json.Marshal(emptySlice) + require.NoError(t, err) + assert.Contains(t, string(emptyData), `"slice_field":[]`) + + setData, err := json.Marshal(setSlice) + require.NoError(t, err) + assert.Contains(t, string(setData), `"slice_field":["a","b"]`) + }) + + t.Run("mixed states container", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), // set to value + IntField: From[int](nil), // set to nil + StructField: From(ptrFrom(TestStruct{Name: "Alice", Age: 25})), // set to value + } + + // Verify states + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.NotContains(t, result, "slice_field") // unset, so omitted + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "Alice", structResult["name"]) + assert.Equal(t, float64(25), structResult["age"]) + }) + + t.Run("JSON unmarshaling preserves states", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing, some null, some with values + jsonData := `{ + "string_field": "test", + "int_field": null, + "struct_field": {"name": "Bob", "age": 35} + }` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // string_field: present with value + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", stringVal) + + // int_field: present but null + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + // slice_field: missing from JSON, should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) + + // struct_field: present with value + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Bob", Age: 35}, structVal) + }) +} + +// TestNilVsUnsetDistinction tests the key feature of distinguishing nil from unset +func TestNilVsUnsetDistinction(t *testing.T) { + t.Parallel() + t.Run("explicit nil vs unset", func(t *testing.T) { + t.Parallel() + // Explicitly set to nil + explicitNil := From[string](nil) + + // Unset + var unset OptionalNullable[string] + + // Both are null, but only one is set + assert.True(t, explicitNil.IsNull()) + assert.True(t, explicitNil.IsSet()) + + assert.False(t, unset.IsNull()) // Unset is not null + assert.False(t, unset.IsSet()) + + // Get behavior differs + got1, ok1 := explicitNil.GetOrZero() + got2, ok2 := unset.GetOrZero() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Equal(t, "", got1) // both return zero value + assert.Equal(t, "", got2) + + // Get behavior differs + ptr1, ok1 := explicitNil.Get() + ptr2, ok2 := unset.Get() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Nil(t, ptr1) // both return nil pointer + assert.Nil(t, ptr2) + }) + + t.Run("empty slice vs nil slice vs unset", func(t *testing.T) { + t.Parallel() + // Empty slice + emptyNullable := From(ptrFrom([]string{})) + + // Nil slice + nilNullable := From[[]string](nil) + + // Unset + var unsetNullable OptionalNullable[[]string] + + // All have different characteristics + assert.True(t, emptyNullable.IsSet()) + assert.False(t, emptyNullable.IsNull()) + + assert.True(t, nilNullable.IsSet()) + assert.True(t, nilNullable.IsNull()) + + assert.False(t, unsetNullable.IsSet()) + assert.False(t, unsetNullable.IsNull()) // Unset is not null + + // Get behavior + got1, ok1 := emptyNullable.GetOrZero() + got2, ok2 := nilNullable.GetOrZero() + got3, ok3 := unsetNullable.GetOrZero() + + assert.True(t, ok1) + assert.Equal(t, []string{}, got1) + + assert.True(t, ok2) + assert.Nil(t, got2) + + assert.False(t, ok3) + assert.Nil(t, got3) + }) +} + +// TestJSONOmitEmpty tests behavior with omitempty tag +func TestJSONOmitEmpty(t *testing.T) { + t.Parallel() + t.Run("marshal with omitempty", func(t *testing.T) { + t.Parallel() + // Test container with various nullable states + container := TestContainer{ + StringField: From(ptrFrom("test")), + IntField: From(ptrFrom(42)), + StructField: From[TestStruct](nil), // explicitly nil + } + + data, err := json.Marshal(container) + require.NoError(t, err) + + // Parse back to verify structure + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // Should contain set fields + assert.Contains(t, result, "string_field") + assert.Contains(t, result, "int_field") + assert.Contains(t, result, "struct_field") + + // Should not contain unset field (due to omitempty) + // Note: This depends on how the marshaling handles unset fields + // The current implementation doesn't handle this case properly (see TODO) + }) + + t.Run("unmarshal missing fields", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing + jsonData := `{"string_field": "test", "int_field": null}` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // Present fields should be set + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + got, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + + // Null field should be set to nil + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + // Missing fields should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.StructField.IsSet()) + }) +} + +// TestEdgeCases tests various edge cases +func TestEdgeCases(t *testing.T) { + t.Parallel() + t.Run("zero values", func(t *testing.T) { + t.Parallel() + // Test with zero values that are not nil + intNullable := From(ptrFrom(0)) + stringNullable := From(ptrFrom("")) + + assert.True(t, intNullable.IsSet()) + assert.False(t, intNullable.IsNull()) + got, ok := intNullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, got) + + assert.True(t, stringNullable.IsSet()) + assert.False(t, stringNullable.IsNull()) + got2, ok2 := stringNullable.GetOrZero() + assert.True(t, ok2) + assert.Equal(t, "", got2) + }) + + t.Run("pointer to pointer", func(t *testing.T) { + t.Parallel() + // Test with pointer to pointer type + inner := "test" + nullable := From(ptrFrom(&inner)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, &inner, got) + assert.Equal(t, "test", *got) + }) + + t.Run("complex struct", func(t *testing.T) { + t.Parallel() + complexStruct := struct { + Name string + Values []int + Metadata map[string]string + }{ + Name: "complex", + Values: []int{1, 2, 3}, + Metadata: map[string]string{ + "key1": "value1", + "key2": "value2", + }, + } + + nullable := From(ptrFrom(complexStruct)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, complexStruct, got) + }) +} + +// TestDoublePointers tests comprehensive double pointer scenarios +func TestDoublePointers(t *testing.T) { + t.Parallel() + + t.Run("string double pointer with value", func(t *testing.T) { + t.Parallel() + inner := "hello world" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, "hello world", *got) + }) + + t.Run("int double pointer with value", func(t *testing.T) { + t.Parallel() + inner := 42 + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, 42, *got) + }) + + t.Run("double pointer to nil", func(t *testing.T) { + t.Parallel() + var ptr *string = nil + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, got) + }) + + t.Run("nil double pointer", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("unset double pointer", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("double pointer modification", func(t *testing.T) { + t.Parallel() + inner := "original" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", *got) + + // Modify through double pointer + *got = "modified" + assert.Equal(t, "modified", inner) + assert.Equal(t, "modified", *got) + }) + + t.Run("double pointer to struct", func(t *testing.T) { + t.Parallel() + inner := TestStruct{Name: "Alice", Age: 30} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, TestStruct{Name: "Alice", Age: 30}, *got) + + // Modify through double pointer + (*got).Name = "Bob" + assert.Equal(t, "Bob", inner.Name) + assert.Equal(t, "Bob", (*got).Name) + }) + + t.Run("double pointer to slice", func(t *testing.T) { + t.Parallel() + inner := []string{"a", "b", "c"} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{"a", "b", "c"}, *got) + + // Modify through double pointer + *got = append(*got, "d") + assert.Equal(t, []string{"a", "b", "c", "d"}, inner) + assert.Equal(t, []string{"a", "b", "c", "d"}, *got) + }) + + t.Run("double pointer to empty slice", func(t *testing.T) { + t.Parallel() + inner := []string{} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{}, *got) + }) + + t.Run("double pointer to nil slice", func(t *testing.T) { + t.Parallel() + var inner []string = nil + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, *got) + }) + + t.Run("double pointer JSON marshaling", func(t *testing.T) { + t.Parallel() + inner := "json test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"json test"`, string(data)) + }) + + t.Run("double pointer JSON unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`"json test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.NotNil(t, got) + assert.Equal(t, "json test", *got) + }) + + t.Run("double pointer JSON null marshaling", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("double pointer JSON null unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer round trip", func(t *testing.T) { + t.Parallel() + inner := "round trip test" + ptr := &inner + nullable1 := From(ptrFrom(ptr)) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[*string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare states + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + + // Values should be equal + assert.Equal(t, *got1, *got2) + }) + + t.Run("triple pointer", func(t *testing.T) { + t.Parallel() + inner := "triple" + ptr1 := &inner + ptr2 := &ptr1 + nullable := From(ptrFrom(ptr2)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr2, got) + assert.Equal(t, ptr1, *got) + assert.Equal(t, "triple", **got) + }) + + t.Run("double pointer set and unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Set to double pointer + inner := "set test" + ptr := &inner + nullable.Set(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "set test", *got) + + // Set to nil + nullable.Set(nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer Get method", func(t *testing.T) { + t.Parallel() + inner := "get test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Test Get method + gotPtr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, gotPtr) + assert.Equal(t, ptr, *gotPtr) + assert.Equal(t, "get test", **gotPtr) + + // Test with nil + nilNullable := From[*string](nil) + gotPtr, ok = nilNullable.Get() + assert.True(t, ok) + assert.Nil(t, gotPtr) + + // Test with unset + var unsetNullable OptionalNullable[*string] + gotPtr, ok = unsetNullable.Get() + assert.False(t, ok) + assert.Nil(t, gotPtr) + }) + + t.Run("double pointer zero values", func(t *testing.T) { + t.Parallel() + // Test with zero value string + inner := "" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", *got) + + // Test with zero value int + innerInt := 0 + ptrInt := &innerInt + nullableInt := From(ptrFrom(ptrInt)) + + assert.True(t, nullableInt.IsSet()) + assert.False(t, nullableInt.IsNull()) + + gotInt, okInt := nullableInt.GetOrZero() + assert.True(t, okInt) + assert.Equal(t, 0, *gotInt) + }) +} + +// TestAsOptionalNullable tests the AsOptionalNullable helper function +func TestAsOptionalNullable(t *testing.T) { + t.Parallel() + + t.Run("with nullable string", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with nullable int", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, 42, value) + }) + + t.Run("with nullable nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Nil(t, value) + }) + + t.Run("with unset nullable", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable string", func(t *testing.T) { + t.Parallel() + regularString := "not nullable" + reflectValue := reflect.ValueOf(regularString) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable int", func(t *testing.T) { + t.Parallel() + regularInt := 42 + reflectValue := reflect.ValueOf(regularInt) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable map", func(t *testing.T) { + t.Parallel() + regularMap := map[string]int{"key": 42} + reflectValue := reflect.ValueOf(regularMap) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable struct", func(t *testing.T) { + t.Parallel() + regularStruct := TestStruct{Name: "test", Age: 30} + reflectValue := reflect.ValueOf(regularStruct) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with nullable double pointer", func(t *testing.T) { + t.Parallel() + inner := "test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, ptr, value) + assert.Equal(t, "test", *value.(*string)) + }) + + t.Run("with nullable slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, []string{"a", "b", "c"}, value) + }) + + t.Run("with nullable struct", func(t *testing.T) { + t.Parallel() + testStruct := TestStruct{Name: "Alice", Age: 25} + nullable := From(ptrFrom(testStruct)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, testStruct, value) + }) + + t.Run("with pointer to nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + ptrToNullable := &nullable + reflectValue := reflect.ValueOf(ptrToNullable) + + // This should work since the pointer to nullable still contains a nullable + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with interface containing nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + var iface interface{} = nullable + reflectValue := reflect.ValueOf(iface) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) +} diff --git a/internal/sdk/public.go b/internal/sdk/public.go deleted file mode 100644 index bc7a762..0000000 --- a/internal/sdk/public.go +++ /dev/null @@ -1,3922 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package sdk - -import ( - "bytes" - "context" - "fmt" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" - "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" - "net/http" - "net/url" -) - -// Public APIs -type Public struct { - rootSDK *SDK - sdkConfiguration config.SDKConfiguration - hooks *hooks.Hooks -} - -func newPublic(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Public { - return &Public{ - rootSDK: rootSDK, - sdkConfiguration: sdkConfig, - hooks: hooks, - } -} - -// CheckContactExists - checkContactExists -// True if contact with given identifiers exists. -func (s *Public) CheckContactExists(ctx context.Context, request operations.CheckContactExistsRequest, opts ...operations.Option) (*operations.CheckContactExistsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/contact/exists") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "checkContactExists", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "ContactExistsRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CheckContactExistsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.CheckContactExistsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 404: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ConfirmUser - confirmUser -// Confirm a portal user -func (s *Public) ConfirmUser(ctx context.Context, request operations.ConfirmUserRequest, opts ...operations.Option) (*operations.ConfirmUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/user/confirm") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "confirmUser", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ConfirmUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ConfirmUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 301: - case httpRes.StatusCode == 400: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.ConfirmUserPublicResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object1 = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// ConfirmUserWithUserID - confirmUserWithUserId -// Confirm a portal user -func (s *Public) ConfirmUserWithUserID(ctx context.Context, request operations.ConfirmUserWithUserIDRequest, opts ...operations.Option) (*operations.ConfirmUserWithUserIDResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/user/confirm/{id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "confirmUserWithUserId", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.ConfirmUserWithUserIDResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 301: - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// CreateUser - createUser -// Registers a portal user -func (s *Public) CreateUser(ctx context.Context, request operations.CreateUserRequest, opts ...operations.Option) (*operations.CreateUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/user") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "createUser", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "CreateUserRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.CreateUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 201: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.CreateUserResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// DeRegisterMLoginUser - deRegisterMLoginUser -// Deregisters a user from the M Login client -func (s *Public) DeRegisterMLoginUser(ctx context.Context, request operations.DeRegisterMLoginUserRequest, opts ...operations.Option) (*operations.DeRegisterMLoginUserResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/public/m-login/deregister/{client_id}/{user_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "deRegisterMLoginUser", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.DeRegisterMLoginUserResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 204: - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetOrganizationSettingsByDomain - getOrganizationSettingsByDomain -// Retrieves organization settings by domain. Only public organization settings are returned. -func (s *Public) GetOrganizationSettingsByDomain(ctx context.Context, request operations.GetOrganizationSettingsByDomainRequest, opts ...operations.Option) (*operations.GetOrganizationSettingsByDomainResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/org/settings") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getOrganizationSettingsByDomain", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetOrganizationSettingsByDomainResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetOrganizationSettingsByDomainResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPortalConfigByDomain - getPortalConfigByDomain -// Retrieves the portal configuration by domain. -func (s *Public) GetPortalConfigByDomain(ctx context.Context, request operations.GetPortalConfigByDomainRequest, opts ...operations.Option) (*operations.GetPortalConfigByDomainResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPortalConfigByDomain", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPortalConfigByDomainResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfig - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfig = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPublicPages - getPublicPages -// Fetch all public portal pages -func (s *Public) GetPublicPages(ctx context.Context, request operations.GetPublicPagesRequest, opts ...operations.Option) (*operations.GetPublicPagesResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/pages") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPublicPages", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPublicPagesResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []shared.Page - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Classes = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPublicPortalConfig - getPublicPortalConfig -// Retrieves the public portal configuration. -func (s *Public) GetPublicPortalConfig(ctx context.Context, request operations.GetPublicPortalConfigRequest, opts ...operations.Option) (*operations.GetPublicPortalConfigResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/portal/config") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPublicPortalConfig", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPublicPortalConfigResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PortalConfig - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PortalConfig = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPublicPortalExtensionDetails - getPublicPortalExtensionDetails -// Get public extension details shown to end customers and configuring users. -func (s *Public) GetPublicPortalExtensionDetails(ctx context.Context, request operations.GetPublicPortalExtensionDetailsRequest, opts ...operations.Option) (*operations.GetPublicPortalExtensionDetailsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/extensions") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPublicPortalExtensionDetails", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPublicPortalExtensionDetailsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.PublicExtensionCapabilities - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.PublicExtensionCapabilities = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetPublicPortalWidgets - getPublicPortalWidgets -// Retrieves the public widgets of a portal -func (s *Public) GetPublicPortalWidgets(ctx context.Context, request operations.GetPublicPortalWidgetsRequest, opts ...operations.Option) (*operations.GetPublicPortalWidgetsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public-widgets") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getPublicPortalWidgets", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetPublicPortalWidgetsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.UpsertPortalWidget - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpsertPortalWidget = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetSchemasByDomain - getSchemasByDomain -// Retrieves schemas by domain. Only schemas and attributes used on public pages are returned. -func (s *Public) GetSchemasByDomain(ctx context.Context, request operations.GetSchemasByDomainRequest, opts ...operations.Option) (*operations.GetSchemasByDomainResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/schemas") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getSchemasByDomain", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetSchemasByDomainResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetSchemasByDomainResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// GetUserEntryPoint - getUserEntryPoint -// Get the entry point for the user -func (s *Public) GetUserEntryPoint(ctx context.Context, request operations.GetUserEntryPointRequest, opts ...operations.Option) (*operations.GetUserEntryPointResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/user/entry-point") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "getUserEntryPoint", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.GetUserEntryPointResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.GetUserEntryPointResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// NotifyMLoginInterestChange - notifyMLoginInterestChange -// Notifies the interest change of a user in the M Login client -func (s *Public) NotifyMLoginInterestChange(ctx context.Context, request operations.NotifyMLoginInterestChangeRequest, opts ...operations.Option) (*operations.NotifyMLoginInterestChangeResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/portal/public/m-login/notify-interest-change/{client_id}/{user_id}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "notifyMLoginInterestChange", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.NotifyMLoginInterestChangeResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - case httpRes.StatusCode == 401: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SsoCallback - ssoCallback -// Handles the callback from the external SSO provider, validates the authorization `code` -// and generates a external provider token to be used with the CUSTOM_AUTH flow against Cognito. -func (s *Public) SsoCallback(ctx context.Context, request operations.SsoCallbackRequest, opts ...operations.Option) (*operations.SsoCallbackResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/sso/callback") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "ssoCallback", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "SSOCallbackRequest", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SsoCallbackResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.SSOCallbackResponse - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.SSOCallbackResponse = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// SsoRedirect - ssoRedirect -// Handles the redirect from the external SSO provider. Validates the authorization `code` and `state` received from the provider. -// Redirects the user to the provided `web_uri` with the validated credentials. -func (s *Public) SsoRedirect(ctx context.Context, request operations.SsoRedirectRequest, opts ...operations.Option) (*operations.SsoRedirectResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/sso/redirect") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "ssoRedirect", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RequestBody", "multipart", `request:"mediaType=multipart/form-data"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) - 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) - if reqContentType != "" { - 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) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SsoRedirectResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 301: - res.Headers = httpRes.Header - - case httpRes.StatusCode == 400: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UserExists - userExists -// Checks whether a user exists in the portal -func (s *Public) UserExists(ctx context.Context, request operations.UserExistsRequest, opts ...operations.Option) (*operations.UserExistsResponse, error) { - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := url.JoinPath(baseURL, "/v2/portal/public/user/exists") - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - hookCtx := hooks.HookContext{ - SDK: s.rootSDK, - SDKConfiguration: s.sdkConfiguration, - BaseURL: baseURL, - Context: ctx, - OperationID: "userExists", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 5000, - MaxInterval: 60000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { - copyBody, err := req.GetBody() - - if err != nil { - return nil, err - } - - req.Body = copyBody - } - - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.UserExistsResponse{ - StatusCode: httpRes.StatusCode, - ContentType: httpRes.Header.Get("Content-Type"), - RawResponse: httpRes, - } - - switch { - case httpRes.StatusCode == 200: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out operations.UserExistsResponseBody - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.Object = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 500: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out shared.ErrorResp - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ErrorResp = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/internal/sdk/roles.go b/internal/sdk/roles.go new file mode 100644 index 0000000..caa74ba --- /dev/null +++ b/internal/sdk/roles.go @@ -0,0 +1,1626 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package sdk + +import ( + "bytes" + "context" + "fmt" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/config" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/hooks" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/internal/utils" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/errors" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/operations" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/models/shared" + "github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk/retry" + "net/http" + "net/url" +) + +// Roles - Manage roles and grants +type Roles struct { + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks +} + +func newRoles(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Roles { + return &Roles{ + rootSDK: rootSDK, + sdkConfiguration: sdkConfig, + hooks: hooks, + } +} + +// CreateRole - createRole +// Create role +func (s *Roles) CreateRole(ctx context.Context, request *shared.CreateRolePayload, opts ...operations.Option) (*operations.CreateRoleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/roles") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createRole", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + 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) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateRoleResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Role + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Role = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// DeleteRole - deleteRole +// Delete role by id +func (s *Roles) DeleteRole(ctx context.Context, request operations.DeleteRoleRequest, opts ...operations.Option) (*operations.DeleteRoleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/roles/{roleId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteRole", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteRoleResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Role + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Role = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// GetRole - getRole +// Get role by id +func (s *Roles) GetRole(ctx context.Context, request operations.GetRoleRequest, opts ...operations.Option) (*operations.GetRoleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/roles/{roleId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getRole", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetRoleResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Role + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Role = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ListAllRoles - listAllRoles +// Returns list of all roles in organization +func (s *Roles) ListAllRoles(ctx context.Context, opts ...operations.Option) (*operations.ListAllRolesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/roles") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listAllRoles", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListAllRolesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out operations.ListAllRolesResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ListCurrentRoles - listCurrentRoles +// Returns roles and grants assigned to current user +func (s *Roles) ListCurrentRoles(ctx context.Context, opts ...operations.Option) (*operations.ListCurrentRolesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/me") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listCurrentRoles", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, 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) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListCurrentRolesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out operations.ListCurrentRolesResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// PutRole - putRole +// Create or update role +func (s *Roles) PutRole(ctx context.Context, request operations.PutRoleRequest, opts ...operations.Option) (*operations.PutRoleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/permissions/roles/{roleId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "putRole", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "RolePayload", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + 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) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.PutRoleResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out shared.Role + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Role = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// RefreshPermissions - refreshPermissions +// Makes sure the user has a role in the organization +func (s *Roles) RefreshPermissions(ctx context.Context, opts ...operations.Option) (*operations.RefreshPermissionsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/refresh") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "refreshPermissions", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "*/*") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RefreshPermissionsResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// SearchRoles - searchRoles +// Search Roles +func (s *Roles) SearchRoles(ctx context.Context, request *shared.RoleSearchInput, opts ...operations.Option) (*operations.SearchRolesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/v1/permissions/roles:search") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "searchRoles", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + 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) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } else { + retryConfig = &retry.Config{ + Strategy: "backoff", Backoff: &retry.BackoffStrategy{ + InitialInterval: 5000, + MaxInterval: 60000, + Exponent: 1.5, + MaxElapsedTime: 3600000, + }, + RetryConnectionErrors: true, + } + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "5XX", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.SearchRolesResponse{ + StatusCode: httpRes.StatusCode, + ContentType: httpRes.Header.Get("Content-Type"), + RawResponse: httpRes, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out operations.SearchRolesResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, errors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index 6d8b109..02526a8 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -2,7 +2,7 @@ package sdk -// Generated from OpenAPI doc version 1.0.0 and generator version 2.694.1 +// Generated from OpenAPI doc version 1.0.0 and generator version 2.731.6 import ( "context" @@ -18,8 +18,7 @@ import ( // ServerList contains the list of servers available to the SDK var ServerList = []string{ - // Production environment - "https://customer-portal-api.sls.epilot.io/", + "https://permissions.sls.epilot.io", } // HTTPClient provides an interface for supplying the SDK with a custom HTTP client @@ -48,19 +47,13 @@ func Float64(f float64) *float64 { return &f } // Pointer provides a helper function to return a pointer to a type func Pointer[T any](v T) *T { return &v } -// SDK - Portal API: Backend for epilot portals - End Customer Portal & Installer Portal +// SDK - Permissions API: Flexible Role-based Access Control for epilot type SDK struct { SDKVersion string - // APIs defined for a ECP Admin - ECPAdmin *ECPAdmin - // APIs defined for a portal user - Ecp *Ecp - Balance *Balance - Activity *Activity - Internal *Internal - // Public APIs - Public *Public - Login *Login + // Assign roles to users + Assignments *Assignments + // Manage roles and grants + Roles *Roles sdkConfiguration config.SDKConfiguration hooks *hooks.Hooks @@ -136,9 +129,9 @@ func WithTimeout(timeout time.Duration) SDKOption { // New creates a new instance of the SDK with the provided options func New(opts ...SDKOption) *SDK { sdk := &SDK{ - SDKVersion: "0.25.16", + SDKVersion: "0.26.0", sdkConfiguration: config.SDKConfiguration{ - UserAgent: "speakeasy-sdk/terraform 0.25.16 2.694.1 1.0.0 github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk", + UserAgent: "speakeasy-sdk/terraform 0.26.0 2.731.6 1.0.0 github.com/epilot-dev/terraform-provider-epilot-portal/internal/sdk", ServerList: ServerList, }, hooks: hooks.New(), @@ -159,13 +152,8 @@ func New(opts ...SDKOption) *SDK { sdk.sdkConfiguration.ServerURL = serverURL } - sdk.ECPAdmin = newECPAdmin(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Ecp = newEcp(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Balance = newBalance(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Activity = newActivity(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Internal = newInternal(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Public = newPublic(sdk, sdk.sdkConfiguration, sdk.hooks) - sdk.Login = newLogin(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.Assignments = newAssignments(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.Roles = newRoles(sdk, sdk.sdkConfiguration, sdk.hooks) return sdk } diff --git a/internal/sdk/types/decimal.go b/internal/sdk/types/decimal.go deleted file mode 100644 index d8429bc..0000000 --- a/internal/sdk/types/decimal.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package types - -import ( - "fmt" - - "github.com/ericlagergren/decimal" -) - -// MustNewDecimalFromString returns an instance of Decimal from a string -// Avoid using this function in production code. -func MustNewDecimalFromString(s string) *decimal.Big { - d, ok := new(decimal.Big).SetString(s) - if !ok { - panic(fmt.Errorf("failed to parse string as decimal.Big")) - } - - return d -}