diff --git a/.gitignore b/.gitignore index 24fcca4..b5ac69a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.env +.env.local .terraform .terraform* *.tfstate* diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 7edf241..638ef74 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,37 +1,39 @@ lockVersion: 2.0.0 id: a994bf58-5e2d-4beb-ac64-cac102ef5b7f management: - docChecksum: 780e9f1d320c0dcdb4791fb0cffed21d + docChecksum: 61640edaf1ba95e446d396cfa38dc6b5 docVersion: 2.0.0 - speakeasyVersion: 1.477.0 - generationVersion: 2.497.0 - releaseVersion: 0.10.5 - configChecksum: 0d54f4c0a4e528de85d26e7b6add6cf5 + speakeasyVersion: 1.651.0 + generationVersion: 2.745.2 + releaseVersion: 0.11.0 + configChecksum: 4b24cfba801271c22029c02ec711a28a + repoURL: https://github.com/epilot-dev/terraform-provider-epilot-usergroup.git features: terraform: additionalDependencies: 0.1.0 - additionalProperties: 0.1.2 - constsAndDefaults: 0.2.0 - core: 3.29.0 - deprecations: 2.81.1 - envVarSecurityUsage: 0.1.0 - globalSecurity: 2.81.9 - globalServerURLs: 2.82.1 + additionalProperties: 0.1.3 + constsAndDefaults: 0.3.0 + core: 3.46.8 + deprecations: 2.82.0 + globalSecurity: 2.82.1 + globalServerURLs: 2.83.0 inputOutputModels: 2.83.0 nullables: 0.0.0 - retries: 2.81.2 + retries: 2.81.4 generatedFiles: - .gitattributes - USAGE.md - - examples/README.md - examples/data-sources/epilot-usergroup_user_group/data-source.tf - examples/provider/provider.tf + - examples/resources/epilot-usergroup_user_group/import-by-string-id.tf - examples/resources/epilot-usergroup_user_group/import.sh - examples/resources/epilot-usergroup_user_group/resource.tf - go.mod - go.sum - internal/planmodifiers/boolplanmodifier/suppress_diff.go + - internal/planmodifiers/float32planmodifier/suppress_diff.go - internal/planmodifiers/float64planmodifier/suppress_diff.go + - internal/planmodifiers/int32planmodifier/suppress_diff.go - internal/planmodifiers/int64planmodifier/suppress_diff.go - internal/planmodifiers/listplanmodifier/suppress_diff.go - internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -55,13 +57,18 @@ generatedFiles: - internal/provider/reflect/primitive.go - internal/provider/reflect/slice.go - internal/provider/reflect/struct.go + - internal/provider/typeconvert/date.go + - internal/provider/typeconvert/datetime.go + - internal/provider/typeconvert/int.go - internal/provider/usergroup_data_source.go - internal/provider/usergroup_data_source_sdk.go - internal/provider/usergroup_resource.go - internal/provider/usergroup_resource_sdk.go - internal/provider/utils.go - internal/sdk/.gitattributes + - internal/sdk/docs/models/operations/option.md - internal/sdk/group.go + - internal/sdk/internal/config/sdkconfiguration.go - internal/sdk/internal/hooks/hooks.go - internal/sdk/internal/utils/contenttype.go - internal/sdk/internal/utils/env.go @@ -116,12 +123,13 @@ generatedFiles: - internal/sdk/models/shared/userinvitationpayload.go - internal/sdk/models/shared/userv2.go - internal/sdk/models/shared/userverificationpayload.go + - internal/sdk/optionalnullable/optionalnullable.go + - internal/sdk/optionalnullable/optionalnullable_test.go - internal/sdk/retry/config.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/sdk/userv1.go - internal/sdk/userv2.go @@ -130,7 +138,9 @@ generatedFiles: - internal/validators/JSONParseValidator.go - internal/validators/RFC3339Validator.go - internal/validators/boolvalidators/not_null.go + - internal/validators/float32validators/not_null.go - internal/validators/float64validators/not_null.go + - internal/validators/int32validators/not_null.go - internal/validators/int64validators/not_null.go - internal/validators/listvalidators/not_null.go - internal/validators/mapvalidators/not_null.go @@ -145,20 +155,20 @@ examples: signUpUser: speakeasy-default-sign-up-user: requestBody: - application/json: {"organization_detail": {"type": "Partner", "name": "Epilot", "pricing_tier": "professional", "email": "Meta_Durgan26@gmail.com", "is_privacy_policy_checked": false, "is_terms_and_conditions_checked": false}, "user_detail": {"full_name": "Example user", "email": "Brown.Zulauf-Ruecker@yahoo.com", "password": "AKjhdakjsdh@!34"}, "language": "en"} + application/json: {"organization_detail": {"type": "Vendor", "name": "Epilot", "pricing_tier": "professional", "email": "Raquel_Haag@hotmail.com", "is_privacy_policy_checked": false, "is_terms_and_conditions_checked": false}, "user_detail": {"full_name": "Example user", "email": "Shemar_Mayert28@yahoo.com", "password": "AKjhdakjsdh@!34"}, "language": "en"} responses: "200": - application/json: {"user": {"id": "", "organization_id": "", "email": "Kylee94@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]}, "organization": {"name": "Epilot", "signature": "

Thanks

", "symbol": "EPI", "pricing_tier": "professional", "email": "someone@epilot.cloud", "phone": "49123123123", "website": "https://epilot.cloud", "logo_url": "https://epilot-playground-organization-data.s3.eu-central-1.amazonaws.com/epilot-logo.png", "logo_thumbnail_url": "https://epilot-playground-organization-data.s3.eu-central-1.amazonaws.com/epilot-logo.png", "is_unlicensed_org": false, "cognito_details": {"cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_user_pool_arn": "arn:aws:cognito-idp:eu-central-1:123456789012:userpool/eu-central-sample"}}} + application/json: {"user": {"id": "", "organization_id": "", "email": "Melvina51@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]}, "organization": {"name": "Epilot", "signature": "

Thanks

", "symbol": "EPI", "pricing_tier": "professional", "email": "someone@epilot.cloud", "phone": "49123123123", "website": "https://epilot.cloud", "logo_url": "https://epilot-playground-organization-data.s3.eu-central-1.amazonaws.com/epilot-logo.png", "logo_thumbnail_url": "https://epilot-playground-organization-data.s3.eu-central-1.amazonaws.com/epilot-logo.png", "is_unlicensed_org": false, "cognito_details": {"cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_user_pool_arn": "arn:aws:cognito-idp:eu-central-1:123456789012:userpool/eu-central-sample"}}} getMeV2: speakeasy-default-get-me-v2: responses: "200": - application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} listUsersV2: speakeasy-default-list-users-v2: responses: "200": - application/json: {"results": [{"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]}, {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]}]} + application/json: {"results": [{"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]}]} getUserV2: speakeasy-default-get-user-v2: parameters: @@ -173,10 +183,10 @@ examples: path: id: "" requestBody: - application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} responses: "200": - application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} deleteUserV2: speakeasy-default-delete-user-v2: parameters: @@ -184,7 +194,7 @@ examples: id: "" responses: "200": - application/json: {"id": "", "organization_id": "", "email": "Freddy64@gmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": []} + application/json: {"id": "", "organization_id": "", "email": "Adeline.Morar37@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} inviteUser: speakeasy-default-invite-user: requestBody: @@ -198,7 +208,7 @@ examples: application/json: {"email": "test@example.com", "language": "en"} responses: "200": - application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"display_name": "Example User", "department": "Sales", "phone": "1234567890", "secondary_phone": "1234567890", "mfa_enabled": false, "phone_verified": true, "signature": "

Thanks

", "is_signature_enabled": true, "preferred_language": "de", "custom_start_page": "/app/dashboard", "feature_preferences": {"feature_name": true}, "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "favorites": {"entity_views": {"opportunity": "891a5409850abf8b92bd2cb7bdd2844d32ce6bec", "order": "628aee91-7c2f-4047-ab0d-433582a19c49"}, "dashboard": "751ff121-9ac2-4511-a2e6-851f11287380"}, "email_notification_setting": {"added_participant_opportunity": true, "assigned_opportunity": true, "assigned_task": true, "comment_opportunity": true, "deleted_task": true, "escalated_task": true, "message_receive_opportunity": true, "message_send_opportunity": true, "created_task": true, "created_opportunity_manual": true, "created_opportunity_auto": true, "deleted_opportunity": true}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} getGroupsForUser: speakeasy-default-get-groups-for-user: parameters: @@ -241,10 +251,10 @@ examples: speakeasy-default-get-user-login-parameters-v2: parameters: path: - username: "Eve94" + username: "Pamela_Conn38" responses: "200": - application/json: {"login_parameters": [{"organization_id": "123", "organization_name": "epilot GmbH", "organization_type": "Vendor", "cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_oauth_domain": "epilot-org-123", "cognito_oauth_scopes": ["openid"]}]} + application/json: {"login_parameters": [{"organization_id": "123", "organization_name": "epilot GmbH", "organization_type": "Vendor", "organization_use": "Production", "cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_oauth_domain": "epilot-org-123", "cognito_oauth_scopes": ["openid"]}]} switchOrganization: speakeasy-default-switch-organization: responses: @@ -267,7 +277,6 @@ examples: parameters: path: id: "" - query: {} responses: "200": application/json: {"id": "", "name": "Finance"} @@ -298,12 +307,12 @@ examples: speakeasy-default-get-me: responses: "200": - application/json: {"id": "", "organization_id": "", "email": "Roger77@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"id": "", "organization_id": "", "email": "Cornelius65@gmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} listUsers: speakeasy-default-list-users: responses: "200": - application/json: {"users": [{"id": "", "organization_id": "", "email": "Oswaldo70@gmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": []}, {"id": "", "organization_id": "", "email": "Alan25@yahoo.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}, {"name": "profileImageName", "value": "avatar.png"}]}]} + application/json: {"users": [{"id": "", "organization_id": "", "email": "Lue27@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]}]} getUser: speakeasy-default-get-user: parameters: @@ -311,14 +320,14 @@ examples: id: "" responses: "200": - application/json: {"id": "", "organization_id": "", "email": "Carolyne_Walsh@hotmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": {"0": "<", "1": "v", "2": "a", "3": "l", "4": "u", "5": "e", "6": ">", "original": "https://account-profile-images.epilot.cloud/1/avatar.png", "thumbnail_32": "https://account-profile-images.epilot.cloud/1/avatar_32x32.png"}, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} + application/json: {"id": "", "organization_id": "", "email": "Cortney_Jakubowski@gmail.com", "name": "Example user", "preferred_language": "de", "signature": "

Thanks

", "roles": ["Owner"], "image_uri": null, "properties": [{"name": "profileImageName", "value": "avatar.png"}]} getUserLoginParameters: speakeasy-default-get-user-login-parameters: parameters: path: - username: "Matilda79" + username: "Maybelle66" responses: "200": - application/json: {"login_parameters": [{"organization_id": "123", "organization_name": "epilot GmbH", "organization_type": "Vendor", "cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_oauth_domain": "epilot-org-123", "cognito_oauth_scopes": ["openid"]}, {"organization_id": "123", "organization_name": "epilot GmbH", "organization_type": "Vendor", "cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_oauth_domain": "epilot-org-123", "cognito_oauth_scopes": ["openid"]}]} -examplesVersion: 1.0.0 + application/json: {"login_parameters": [{"organization_id": "123", "organization_name": "epilot GmbH", "organization_type": "Vendor", "organization_use": "Production", "cognito_region": "eu-central-1", "cognito_user_pool_id": "eu-central-sample", "cognito_user_pool_client_id": "asbkh213ehkquwhdi", "cognito_oauth_domain": "epilot-org-123", "cognito_oauth_scopes": ["openid"]}]} +examplesVersion: 1.0.2 generatedTests: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock new file mode 100644 index 0000000..3e7a86c --- /dev/null +++ b/.speakeasy/workflow.lock @@ -0,0 +1,31 @@ +speakeasyVersion: 1.651.0 +sources: + my-source: + sourceNamespace: my-source + sourceRevisionDigest: sha256:7ea416444bca3b48a3741f7e1de17530b8917995cfa7ae4ffaf4fef00bc72f7d + sourceBlobDigest: sha256:b0cdc27b97371a9c5c9ad1d5103926720d69c82f36e9e9d354f1be84b2e8a358 + tags: + - latest + - speakeasy-sdk-regen-1758759560 + - 2.0.0 +targets: + terraform: + source: my-source + sourceNamespace: my-source + sourceRevisionDigest: sha256:7ea416444bca3b48a3741f7e1de17530b8917995cfa7ae4ffaf4fef00bc72f7d + sourceBlobDigest: sha256:b0cdc27b97371a9c5c9ad1d5103926720d69c82f36e9e9d354f1be84b2e8a358 +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + sources: + my-source: + inputs: + - location: https://docs.api.epilot.io/user.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 b1df7b6..ac7c5ff 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ terraform { required_providers { epilot-usergroup = { source = "epilot-dev/epilot-usergroup" - version = "0.10.5" + version = "0.11.0" } } } @@ -82,10 +82,23 @@ User API: Manage users in epilot organization(s) * [Installation](#installation) * [Testing the provider locally](#testing-the-provider-locally) + * [Authentication](#authentication) * [Available Resources and Data Sources](#available-resources-and-data-sources) + +## Authentication + +This provider supports authentication configuration via provider configuration. + +Available configuration: + +| Provider Attribute | Description | +|---|---| +| `epilot_auth` | Authorization header with epilot OAuth2 bearer token. | + + ## Available Resources and Data Sources diff --git a/RELEASES.md b/RELEASES.md index 22a7ee6..ed80f89 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -30,4 +30,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.2.3] . \ No newline at end of file +- [terraform v0.2.3] . + +## 2025-11-09 00:21:46 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.651.0 (2.745.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [terraform v0.11.0] . +### Releases +- [Terraform v0.11.0] https://registry.terraform.io/providers/epilot-dev/epilot-usergroup/0.11.0 - . \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index fbf0017..e7aa794 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,6 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs page_title: "epilot-usergroup Provider" -subcategory: "" description: |- User API: Manage users in epilot organization(s) --- @@ -17,7 +16,7 @@ terraform { required_providers { epilot-usergroup = { source = "epilot-dev/epilot-usergroup" - version = "0.10.5" + version = "0.11.0" } } } @@ -32,5 +31,5 @@ provider "epilot-usergroup" { ### Optional -- `epilot_auth` (String, Sensitive) +- `epilot_auth` (String, Sensitive) Authorization header with epilot OAuth2 bearer token. - `server_url` (String) Server URL (defaults to https://user.sls.epilot.io) diff --git a/docs/resources/user_group.md b/docs/resources/user_group.md index 71669d1..b5cd7f0 100644 --- a/docs/resources/user_group.md +++ b/docs/resources/user_group.md @@ -33,6 +33,17 @@ resource "epilot-usergroup_user_group" "my_usergroup" { 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-usergroup_user_group.my_epilot-usergroup_user_group + id = "..." +} +``` + +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: + ```shell -terraform import epilot-usergroup_user_group.my_epilot-usergroup_user_group "" +terraform import epilot-usergroup_user_group.my_epilot-usergroup_user_group "..." ``` 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/provider/provider.tf b/examples/provider/provider.tf index 1ce9165..32c1187 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { epilot-usergroup = { source = "epilot-dev/epilot-usergroup" - version = "0.10.5" + version = "0.11.0" } } } diff --git a/examples/resources/epilot-usergroup_user_group/import-by-string-id.tf b/examples/resources/epilot-usergroup_user_group/import-by-string-id.tf new file mode 100644 index 0000000..20e4e97 --- /dev/null +++ b/examples/resources/epilot-usergroup_user_group/import-by-string-id.tf @@ -0,0 +1,4 @@ +import { + to = epilot-usergroup_user_group.my_epilot-usergroup_user_group + id = "..." +} diff --git a/examples/resources/epilot-usergroup_user_group/import.sh b/examples/resources/epilot-usergroup_user_group/import.sh index d8ccd74..7a6bc40 100644 --- a/examples/resources/epilot-usergroup_user_group/import.sh +++ b/examples/resources/epilot-usergroup_user_group/import.sh @@ -1 +1 @@ -terraform import epilot-usergroup_user_group.my_epilot-usergroup_user_group "" +terraform import epilot-usergroup_user_group.my_epilot-usergroup_user_group "..." diff --git a/gen.yaml b/gen.yaml index 56cc02b..9b945e9 100755 --- a/gen.yaml +++ b/gen.yaml @@ -4,24 +4,42 @@ generation: maintainOpenAPIOrder: true usageSnippets: optionalPropertyRendering: withExample + sdkInitStyle: constructor useClassNamesForArrayFields: true fixes: - nameResolutionDec2023: false + nameResolutionFeb2025: false parameterOrderingFeb2024: false requestResponseComponentNamesFeb2024: false + securityFeb2025: false + sharedErrorComponentsApr2025: false auth: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false + hoistGlobalSecurity: true + schemas: + allOfMergeStrategy: shallowMerge + requestBodyFieldName: "" + tests: + generateTests: true + generateNewTests: false + skipResponseBodyAssertions: false sdkFlattening: true telemetryEnabled: false terraform: - version: 0.10.5 + version: 0.11.0 additionalDataSources: [] additionalDependencies: {} + additionalEphemeralResources: [] + additionalProviderAttributes: + httpHeaders: "" + tlsSkipVerify: "" additionalResources: [] allowUnknownFieldsInWeakUnions: false author: epilot-dev + baseErrorName: SDKBaseError defaultErrorName: SDKError + enableOperationSecurity: false + enableOperationServers: false enableTypeDeduplication: true environmentVariables: [] imports: @@ -32,6 +50,8 @@ terraform: operations: operations shared: shared webhooks: webhooks + includeEmptyObjects: false inputModelSuffix: input outputModelSuffix: output packageName: epilot-usergroup + unionDeserializationStrategy: populated-fields diff --git a/go.mod b/go.mod index eedda4d..8d57574 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,15 @@ module github.com/epilot-dev/terraform-provider-epilot-usergroup -go 1.22.0 +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.19.4 - github.com/hashicorp/terraform-plugin-framework v1.12.0 - github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 - github.com/hashicorp/terraform-plugin-go v0.24.0 + github.com/hashicorp/terraform-plugin-docs v0.22.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 ( @@ -18,56 +18,59 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.0 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect + github.com/ProtonMail/go-crypto v1.1.6 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect - github.com/cloudflare/circl v1.3.7 // 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 - github.com/hashicorp/cli v1.1.6 // indirect + github.com/hashicorp/cli v1.1.7 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.6.1 // indirect + github.com/hashicorp/go-plugin v1.6.3 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/go-version v1.7.0 // indirect - github.com/hashicorp/hc-install v0.7.0 // indirect - github.com/hashicorp/terraform-exec v0.21.0 // indirect - github.com/hashicorp/terraform-json v0.22.1 // indirect - github.com/hashicorp/terraform-registry-address v0.2.3 // indirect + github.com/hashicorp/hc-install v0.9.2 // indirect + github.com/hashicorp/terraform-exec v0.23.0 // indirect + github.com/hashicorp/terraform-json v0.25.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.5 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/huandu/xstrings v1.3.3 // indirect github.com/imdario/mergo v0.3.15 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/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 github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/yuin/goldmark v1.7.1 // indirect + github.com/yuin/goldmark v1.7.7 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect - github.com/zclconf/go-cty v1.14.4 // indirect + github.com/zclconf/go-cty v1.16.3 // indirect go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect - golang.org/x/crypto v0.24.0 // indirect + golang.org/x/crypto v0.38.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/grpc v1.66.2 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/mod v0.25.0 // indirect + golang.org/x/net v0.39.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.26.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/grpc v1.72.1 // indirect + google.golang.org/protobuf v1.36.6 // indirect gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 762ad5a..e91839d 100644 --- a/go.sum +++ b/go.sum @@ -10,31 +10,29 @@ github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7Y github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= -github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw= +github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= -github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38= +github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s= +github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= @@ -42,21 +40,25 @@ github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3 github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= -github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= +github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= +github.com/go-git/go-git/v5 v5.14.0 h1:/MD3lCrGjCen5WfEAzKg00MJJffKhC8gzS80ycmCi60= +github.com/go-git/go-git/v5 v5.14.0/go.mod h1:Z5Xhoia5PcWA3NF8vRLURn9E5FRhSl7dGj9ItW3Wk5k= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ= +github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= -github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= +github.com/hashicorp/cli v1.1.7 h1:/fZJ+hNdwfTSfsxMBa9WWMlfjUZbX8/LnUxgAd7lCVU= +github.com/hashicorp/cli v1.1.7/go.mod h1:e6Mfpga9OCT1vqzFuoGZiiF/KaG9CbUfO5s3ghU3YgU= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -65,36 +67,38 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-plugin v1.6.1 h1:P7MR2UP6gNKGPp+y7EZw2kOiq4IR9WiqLvp0XOsVdwI= -github.com/hashicorp/go-plugin v1.6.1/go.mod h1:XPHFku2tFo3o3QKFgSYo+cghcUhw1NA1hZyMK0PWAw0= +github.com/hashicorp/go-plugin v1.6.3 h1:xgHB+ZUSYeuJi96WtxEjzi23uh7YQpznjGh0U0UUrwg= +github.com/hashicorp/go-plugin v1.6.3/go.mod h1:MRobyh+Wc/nYy1V4KAXUiYfzxoYhs7V1mlH1Z7iY2h0= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= -github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= -github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= -github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= -github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= -github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= -github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= -github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= -github.com/hashicorp/terraform-plugin-framework v1.12.0 h1:7HKaueHPaikX5/7cbC1r9d1m12iYHY+FlNZEGxQ42CQ= -github.com/hashicorp/terraform-plugin-framework v1.12.0/go.mod h1:N/IOQ2uYjW60Jp39Cp3mw7I/OpC/GfZ0385R0YibmkE= -github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E= -github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo= -github.com/hashicorp/terraform-plugin-go v0.24.0 h1:2WpHhginCdVhFIrWHxDEg6RBn3YaWzR2o6qUeIEat2U= -github.com/hashicorp/terraform-plugin-go v0.24.0/go.mod h1:tUQ53lAsOyYSckFGEefGC5C8BAaO0ENqzFd3bQeuYQg= +github.com/hashicorp/hc-install v0.9.2 h1:v80EtNX4fCVHqzL9Lg/2xkp62bbvQMnvPQ0G+OmtO24= +github.com/hashicorp/hc-install v0.9.2/go.mod h1:XUqBQNnuT4RsxoxiM9ZaUk0NX8hi2h+Lb6/c0OZnC/I= +github.com/hashicorp/terraform-exec v0.23.0 h1:MUiBM1s0CNlRFsCLJuM5wXZrzA3MnPYEsiXmzATMW/I= +github.com/hashicorp/terraform-exec v0.23.0/go.mod h1:mA+qnx1R8eePycfwKkCRk3Wy65mwInvlpAeOwmA7vlY= +github.com/hashicorp/terraform-json v0.25.0 h1:rmNqc/CIfcWawGiwXmRuiXJKEiJu1ntGoxseG1hLhoQ= +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.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= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= -github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= +github.com/hashicorp/terraform-registry-address v0.2.5 h1:2GTftHqmUhVOeuu9CW3kwDkRe4pcBDq0uuK5VJngU1M= +github.com/hashicorp/terraform-registry-address v0.2.5/go.mod h1:PpzXWINwB5kuVS5CA7m1+eO2f1jKb5ZDIxrOPfpnGkg= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= @@ -116,11 +120,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= @@ -135,21 +138,21 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= +github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= -github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8= +github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= @@ -158,8 +161,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -167,34 +170,44 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= -github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark v1.7.7 h1:5m9rrB1sW3JUMToKFQfb+FGt1U7r57IHu5GrYrG2nqU= +github.com/yuin/goldmark v1.7.7/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= -github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= -github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.16.3 h1:osr++gw2T61A8KVYHoQiFbFd1Lh3JOCXc/jFLJXKTxk= +github.com/zclconf/go-cty v1.16.3/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -205,11 +218,10 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -217,20 +229,20 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= diff --git a/internal/planmodifiers/float32planmodifier/suppress_diff.go b/internal/planmodifiers/float32planmodifier/suppress_diff.go new file mode 100644 index 0000000..4f39d85 --- /dev/null +++ b/internal/planmodifiers/float32planmodifier/suppress_diff.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package float32planmodifier + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/planmodifiers/utils" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" +) + +const ( + // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation + ExplicitSuppress = iota +) + +// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown +func SuppressDiff(strategy int) planmodifier.Float32 { + return suppressDiff{ + strategy: strategy, + } +} + +// suppressDiff implements the plan modifier. +type suppressDiff struct { + strategy int +} + +// Description returns a human-readable description of the plan modifier. +func (m suppressDiff) Description(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// MarkdownDescription returns a markdown description of the plan modifier. +func (m suppressDiff) MarkdownDescription(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// PlanModifyFloat32 implements the plan modification logic. +func (m suppressDiff) PlanModifyFloat32(ctx context.Context, req planmodifier.Float32Request, resp *planmodifier.Float32Response) { + // Do nothing if there is a known planned value. + if !req.PlanValue.IsUnknown() { + return + } + + // Do nothing if there is an unknown configuration value + if req.ConfigValue.IsUnknown() { + return + } + + if utils.IsAllStateUnknown(ctx, req.State) { + return + } + + resp.PlanValue = req.StateValue +} diff --git a/internal/planmodifiers/int32planmodifier/suppress_diff.go b/internal/planmodifiers/int32planmodifier/suppress_diff.go new file mode 100644 index 0000000..501c72f --- /dev/null +++ b/internal/planmodifiers/int32planmodifier/suppress_diff.go @@ -0,0 +1,56 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package int32planmodifier + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/planmodifiers/utils" + + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" +) + +const ( + // ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation + ExplicitSuppress = iota +) + +// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown +func SuppressDiff(strategy int) planmodifier.Int32 { + return suppressDiff{ + strategy: strategy, + } +} + +// suppressDiff implements the plan modifier. +type suppressDiff struct { + strategy int +} + +// Description returns a human-readable description of the plan modifier. +func (m suppressDiff) Description(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// MarkdownDescription returns a markdown description of the plan modifier. +func (m suppressDiff) MarkdownDescription(_ context.Context) string { + return "Once set, the value of this attribute in state will not change." +} + +// PlanModifyInt32 implements the plan modification logic. +func (m suppressDiff) PlanModifyInt32(ctx context.Context, req planmodifier.Int32Request, resp *planmodifier.Int32Response) { + // Do nothing if there is a known planned value. + if !req.PlanValue.IsUnknown() { + return + } + + // Do nothing if there is an unknown configuration value + if req.ConfigValue.IsUnknown() { + return + } + + if utils.IsAllStateUnknown(ctx, req.State) { + return + } + + resp.PlanValue = req.StateValue +} diff --git a/internal/planmodifiers/utils/state_check.go b/internal/planmodifiers/utils/state_check.go index 51d5362..0ea64fb 100644 --- a/internal/planmodifiers/utils/state_check.go +++ b/internal/planmodifiers/utils/state_check.go @@ -4,6 +4,7 @@ package utils import ( "context" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/tfsdk" @@ -12,7 +13,7 @@ import ( func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool { attrs := state.Schema.GetAttributes() anyFound := false - for k, _ := range attrs { + for k := range attrs { attrValue := new(attr.Value) state.GetAttribute(ctx, path.Root(k), attrValue) if attrValue != nil && !(*attrValue).IsUnknown() && !(*attrValue).IsNull() { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f5b5a06..bf02e5e 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -7,6 +7,7 @@ import ( "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/shared" "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/ephemeral" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -14,7 +15,8 @@ import ( "net/http" ) -var _ provider.Provider = &EpilotUsergroupProvider{} +var _ provider.Provider = (*EpilotUsergroupProvider)(nil) +var _ provider.ProviderWithEphemeralResources = (*EpilotUsergroupProvider)(nil) type EpilotUsergroupProvider struct { // version is set to the provider version on release, "dev" when the @@ -25,8 +27,8 @@ type EpilotUsergroupProvider struct { // EpilotUsergroupProviderModel describes the provider data model. type EpilotUsergroupProviderModel struct { - ServerURL types.String `tfsdk:"server_url"` EpilotAuth types.String `tfsdk:"epilot_auth"` + ServerURL types.String `tfsdk:"server_url"` } func (p *EpilotUsergroupProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { @@ -36,18 +38,18 @@ func (p *EpilotUsergroupProvider) Metadata(ctx context.Context, req provider.Met func (p *EpilotUsergroupProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ - Description: `User API: Manage users in epilot organization(s)`, Attributes: map[string]schema.Attribute{ - "server_url": schema.StringAttribute{ - MarkdownDescription: "Server URL (defaults to https://user.sls.epilot.io)", + "epilot_auth": schema.StringAttribute{ + MarkdownDescription: `Authorization header with epilot OAuth2 bearer token.`, Optional: true, - Required: false, + Sensitive: true, }, - "epilot_auth": schema.StringAttribute{ - Sensitive: true, - Optional: true, + "server_url": schema.StringAttribute{ + Description: `Server URL (defaults to https://user.sls.epilot.io)`, + Optional: true, }, }, + MarkdownDescription: `User API: Manage users in epilot organization(s)`, } } @@ -60,33 +62,35 @@ func (p *EpilotUsergroupProvider) Configure(ctx context.Context, req provider.Co return } - ServerURL := data.ServerURL.ValueString() + serverUrl := data.ServerURL.ValueString() - if ServerURL == "" { - ServerURL = "https://user.sls.epilot.io" + if serverUrl == "" { + serverUrl = "https://user.sls.epilot.io" } - epilotAuth := new(string) - if !data.EpilotAuth.IsUnknown() && !data.EpilotAuth.IsNull() { - *epilotAuth = data.EpilotAuth.ValueString() - } else { - epilotAuth = nil + security := shared.Security{} + + if !data.EpilotAuth.IsUnknown() { + security.EpilotAuth = data.EpilotAuth.ValueStringPointer() } - security := shared.Security{ - EpilotAuth: epilotAuth, + + providerHTTPTransportOpts := ProviderHTTPTransportOpts{ + SetHeaders: make(map[string]string), + Transport: http.DefaultTransport, } httpClient := http.DefaultClient - httpClient.Transport = NewLoggingHTTPTransport(http.DefaultTransport) + httpClient.Transport = NewProviderHTTPTransport(providerHTTPTransportOpts) opts := []sdk.SDKOption{ - sdk.WithServerURL(ServerURL), + sdk.WithServerURL(serverUrl), sdk.WithSecurity(security), sdk.WithClient(httpClient), } - client := sdk.New(opts...) + client := sdk.New(opts...) resp.DataSourceData = client + resp.EphemeralResourceData = client resp.ResourceData = client } @@ -102,6 +106,10 @@ func (p *EpilotUsergroupProvider) DataSources(ctx context.Context) []func() data } } +func (p *EpilotUsergroupProvider) EphemeralResources(ctx context.Context) []func() ephemeral.EphemeralResource { + return []func() ephemeral.EphemeralResource{} +} + func New(version string) func() provider.Provider { return func() provider.Provider { return &EpilotUsergroupProvider{ diff --git a/internal/provider/typeconvert/date.go b/internal/provider/typeconvert/date.go new file mode 100644 index 0000000..c8cf528 --- /dev/null +++ b/internal/provider/typeconvert/date.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +import ( + sdkTypes "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/types" +) + +// Converts a date types.Date to string. +func DateToString(value sdkTypes.Date) string { + return value.String() +} + +// Converts a date *types.Date to *string. +func DatePointerToStringPointer(value *sdkTypes.Date) *string { + if value == nil { + return nil + } + + stringValue := DateToString(*value) + + return &stringValue +} diff --git a/internal/provider/typeconvert/datetime.go b/internal/provider/typeconvert/datetime.go new file mode 100644 index 0000000..7bfdc55 --- /dev/null +++ b/internal/provider/typeconvert/datetime.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +import ( + "time" +) + +// Converts a date-time time.Time to string. +func TimeToString(value time.Time) string { + return value.Format(time.RFC3339Nano) +} + +// Converts a date-time *time.Time to *string. +func TimePointerToStringPointer(value *time.Time) *string { + if value == nil { + return nil + } + + stringValue := TimeToString(*value) + + return &stringValue +} diff --git a/internal/provider/typeconvert/int.go b/internal/provider/typeconvert/int.go new file mode 100644 index 0000000..54763e7 --- /dev/null +++ b/internal/provider/typeconvert/int.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package typeconvert + +// Converts an *int to *int32. +func IntPointerToInt32Pointer(value *int) *int32 { + if value == nil { + return nil + } + + int32Value := int32(*value) + + return &int32Value +} + +// Converts an *int to *int64. +func IntPointerToInt64Pointer(value *int) *int64 { + if value == nil { + return nil + } + + int64Value := int64(*value) + + return &int64Value +} + +// Converts an *int32 to *int. +func Int32PointerToIntPointer(value *int32) *int { + if value == nil { + return nil + } + + intValue := int(*value) + + return &intValue +} + +// Converts an *int64 to *int32. +func Int64PointerToInt32Pointer(value *int64) *int32 { + if value == nil { + return nil + } + + // This may panic and if it does, represents a schema mismatch between + // response and response types. Request and response types should always + // be consistent with the highest integer size necessary. + int32Value := int32(*value) + + return &int32Value +} diff --git a/internal/provider/usergroup_data_source.go b/internal/provider/usergroup_data_source.go index 640fb61..fc0a07c 100644 --- a/internal/provider/usergroup_data_source.go +++ b/internal/provider/usergroup_data_source.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/operations" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -23,12 +22,13 @@ func NewUserGroupDataSource() datasource.DataSource { // UserGroupDataSource is the data source implementation. type UserGroupDataSource struct { + // Provider configured SDK client. client *sdk.SDK } // UserGroupDataSourceModel describes the data model. type UserGroupDataSourceModel struct { - Hydrate types.Bool `tfsdk:"hydrate"` + Hydrate types.Bool `queryParam:"style=form,explode=true,name=hydrate" tfsdk:"hydrate"` ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` } @@ -98,20 +98,13 @@ func (r *UserGroupDataSource) Read(ctx context.Context, req datasource.ReadReque return } - var id string - id = data.ID.ValueString() + request, requestDiags := data.ToOperationsGetGroupRequest(ctx) + resp.Diagnostics.Append(requestDiags...) - hydrate := new(bool) - if !data.Hydrate.IsUnknown() && !data.Hydrate.IsNull() { - *hydrate = data.Hydrate.ValueBool() - } else { - hydrate = nil - } - request := operations.GetGroupRequest{ - ID: id, - Hydrate: hydrate, + if resp.Diagnostics.HasError() { + return } - res, err := r.client.Group.GetGroup(ctx, request) + res, err := r.client.Group.GetGroup(ctx, *request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) if res != nil && res.RawResponse != nil { @@ -123,10 +116,6 @@ func (r *UserGroupDataSource) Read(ctx context.Context, req datasource.ReadReque 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 @@ -135,7 +124,11 @@ func (r *UserGroupDataSource) Read(ctx context.Context, req datasource.ReadReque resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) return } - data.RefreshFromSharedGroup(res.Group) + resp.Diagnostics.Append(data.RefreshFromSharedGroup(ctx, res.Group)...) + + if resp.Diagnostics.HasError() { + return + } // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/usergroup_data_source_sdk.go b/internal/provider/usergroup_data_source_sdk.go index 662901e..05a8dc4 100644 --- a/internal/provider/usergroup_data_source_sdk.go +++ b/internal/provider/usergroup_data_source_sdk.go @@ -3,13 +3,40 @@ package provider import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/shared" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *UserGroupDataSourceModel) RefreshFromSharedGroup(resp *shared.Group) { +func (r *UserGroupDataSourceModel) RefreshFromSharedGroup(ctx context.Context, resp *shared.Group) diag.Diagnostics { + var diags diag.Diagnostics + if resp != nil { r.ID = types.StringValue(resp.ID) r.Name = types.StringValue(resp.Name) } + + return diags +} + +func (r *UserGroupDataSourceModel) ToOperationsGetGroupRequest(ctx context.Context) (*operations.GetGroupRequest, diag.Diagnostics) { + var diags diag.Diagnostics + + var id string + id = r.ID.ValueString() + + hydrate := new(bool) + if !r.Hydrate.IsUnknown() && !r.Hydrate.IsNull() { + *hydrate = r.Hydrate.ValueBool() + } else { + hydrate = nil + } + out := operations.GetGroupRequest{ + ID: id, + Hydrate: hydrate, + } + + return &out, diags } diff --git a/internal/provider/usergroup_resource.go b/internal/provider/usergroup_resource.go index 1434441..1d51964 100644 --- a/internal/provider/usergroup_resource.go +++ b/internal/provider/usergroup_resource.go @@ -7,7 +7,6 @@ import ( "fmt" speakeasy_stringplanmodifier "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/planmodifiers/stringplanmodifier" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk" - "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/operations" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -27,6 +26,7 @@ func NewUserGroupResource() resource.Resource { // UserGroupResource defines the resource implementation. type UserGroupResource struct { + // Provider configured SDK client. client *sdk.SDK } @@ -98,7 +98,12 @@ func (r *UserGroupResource) Create(ctx context.Context, req resource.CreateReque return } - request := data.ToSharedCreateGroupReq() + request, requestDiags := data.ToSharedCreateGroupReq(ctx) + resp.Diagnostics.Append(requestDiags...) + + if resp.Diagnostics.HasError() { + return + } res, err := r.client.Group.CreateGroup(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -119,8 +124,17 @@ func (r *UserGroupResource) Create(ctx context.Context, req resource.CreateReque resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) return } - data.RefreshFromSharedGroup(res.Group) - refreshPlan(ctx, plan, &data, resp.Diagnostics) + resp.Diagnostics.Append(data.RefreshFromSharedGroup(ctx, res.Group)...) + + 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)...) @@ -144,16 +158,13 @@ func (r *UserGroupResource) Read(ctx context.Context, req resource.ReadRequest, return } - var id string - id = data.ID.ValueString() + request, requestDiags := data.ToOperationsGetGroupRequest(ctx) + resp.Diagnostics.Append(requestDiags...) - // read.user_group.hydrateread.user_group.hydrate impedance mismatch: boolean != classtrace=["UserGroup#create.req"] - var hydrate *bool - request := operations.GetGroupRequest{ - ID: id, - Hydrate: hydrate, + if resp.Diagnostics.HasError() { + return } - res, err := r.client.Group.GetGroup(ctx, request) + res, err := r.client.Group.GetGroup(ctx, *request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) if res != nil && res.RawResponse != nil { @@ -177,7 +188,11 @@ func (r *UserGroupResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.AddError("unexpected response from API. Got an unexpected response body", debugResponse(res.RawResponse)) return } - data.RefreshFromSharedGroup(res.Group) + resp.Diagnostics.Append(data.RefreshFromSharedGroup(ctx, res.Group)...) + + if resp.Diagnostics.HasError() { + return + } // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/usergroup_resource_sdk.go b/internal/provider/usergroup_resource_sdk.go index c105b17..18f096c 100644 --- a/internal/provider/usergroup_resource_sdk.go +++ b/internal/provider/usergroup_resource_sdk.go @@ -3,23 +3,46 @@ package provider import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/operations" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/shared" + "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *UserGroupResourceModel) ToSharedCreateGroupReq() *shared.CreateGroupReq { +func (r *UserGroupResourceModel) RefreshFromSharedGroup(ctx context.Context, resp *shared.Group) diag.Diagnostics { + var diags diag.Diagnostics + + if resp != nil { + r.ID = types.StringValue(resp.ID) + r.Name = types.StringValue(resp.Name) + } + + return diags +} + +func (r *UserGroupResourceModel) ToOperationsGetGroupRequest(ctx context.Context) (*operations.GetGroupRequest, diag.Diagnostics) { + var diags diag.Diagnostics + + var id string + id = r.ID.ValueString() + + out := operations.GetGroupRequest{ + ID: id, + } + + return &out, diags +} + +func (r *UserGroupResourceModel) ToSharedCreateGroupReq(ctx context.Context) (*shared.CreateGroupReq, diag.Diagnostics) { + var diags diag.Diagnostics + var name string name = r.Name.ValueString() out := shared.CreateGroupReq{ Name: name, } - return &out -} -func (r *UserGroupResourceModel) RefreshFromSharedGroup(resp *shared.Group) { - if resp != nil { - r.ID = types.StringValue(resp.ID) - r.Name = types.StringValue(resp.Name) - } + return &out, diags } diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 0e4d2b7..40e3466 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -6,22 +6,22 @@ import ( "bufio" "bytes" "context" - "encoding/json" "errors" "fmt" - tfReflect "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/provider/reflect" + "io" + "net/http" + "net/http/httputil" + "net/textproto" + "strings" + "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" - "io" - "net/http" - "net/http/httputil" - "net/textproto" - "reflect" - "strings" + + tfReflect "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/provider/reflect" ) func debugResponse(response *http.Response) string { @@ -45,19 +45,6 @@ func debugResponse(response *http.Response) string { return fmt.Sprintf("**Request**:\n%s\n**Response**:\n%s", string(dumpReq), string(dumpRes)) } -func reflectJSONKey(data any, key string) reflect.Value { - jsonIfied, err := json.Marshal(data) - if err != nil { - panic(fmt.Errorf("failed to marshal data: %w", err)) - } - var jsonMap map[string]interface{} - err = json.Unmarshal(jsonIfied, &jsonMap) - if err != nil { - panic(fmt.Errorf("failed to unmarshal data: %w", err)) - } - return reflect.ValueOf(jsonMap[key]) -} - func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse, target interface{}) { var plan types.Object var state types.Object @@ -83,26 +70,46 @@ func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.Updat return } - refreshPlan(ctx, plan, target, resp.Diagnostics) + resp.Diagnostics.Append(refreshPlan(ctx, plan, target)...) } -func refreshPlan(ctx context.Context, plan types.Object, target interface{}, diagnostics diag.Diagnostics) { +func refreshPlan(ctx context.Context, plan types.Object, target any) diag.Diagnostics { + var diags diag.Diagnostics + obj := types.ObjectType{AttrTypes: plan.AttributeTypes(ctx)} val, err := plan.ToTerraformValue(ctx) if err != nil { - diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error())) - return + diags.AddError( + "Object Conversion Error", + "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error(), + ) + return diags } - diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ + + diags.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, SourceType: tfReflect.SourceTypePlan, }, path.Empty())...) + + return diags +} + +// Configurable options for the provider HTTP transport. +type ProviderHTTPTransportOpts struct { + // HTTP headers to set on all requests. + SetHeaders map[string]string + + // Underlying HTTP transport. + Transport http.RoundTripper } // Note: this is taken as a more minimal/specific version of https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/logging/logging_http_transport.go -func NewLoggingHTTPTransport(t http.RoundTripper) *loggingHttpTransport { - return &loggingHttpTransport{t} +func NewProviderHTTPTransport(opts ProviderHTTPTransportOpts) *providerHttpTransport { + return &providerHttpTransport{ + setHeaders: opts.SetHeaders, + transport: opts.Transport, + } } const ( @@ -120,14 +127,18 @@ const ( FieldHttpTransactionId = "tf_http_trans_id" ) -type loggingHttpTransport struct { - transport http.RoundTripper +type providerHttpTransport struct { + setHeaders map[string]string + transport http.RoundTripper } -func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { +func (t *providerHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { ctx := req.Context() ctx = t.addTransactionIdField(ctx) + // Set globally defined HTTP headers in the request + t.setRequestHeaders(req) + // Decompose the request bytes in a message (HTTP body) and fields (HTTP headers), then log it fields, err := decomposeRequestForLogging(req) if err != nil { @@ -157,7 +168,8 @@ func (t *loggingHttpTransport) RoundTrip(req *http.Request) (*http.Response, err return res, nil } -func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) context.Context { +// Generates UUID and sets it into the tf_http_trans_id logging field. +func (t *providerHttpTransport) addTransactionIdField(ctx context.Context) context.Context { tId, err := uuid.GenerateUUID() if err != nil { @@ -167,6 +179,13 @@ func (t *loggingHttpTransport) addTransactionIdField(ctx context.Context) contex return tflog.SetField(ctx, FieldHttpTransactionId, tId) } +// Sets globally defined HTTP headers in the request. +func (t *providerHttpTransport) setRequestHeaders(req *http.Request) { + for name, value := range t.setHeaders { + req.Header.Set(name, value) + } +} + func decomposeRequestForLogging(req *http.Request) (map[string]interface{}, error) { fields := make(map[string]interface{}, len(req.Header)+4) fields[FieldHttpOperationType] = OperationHttpRequest diff --git a/internal/sdk/.gitignore b/internal/sdk/.gitignore index f2c012b..04c9c85 100644 --- a/internal/sdk/.gitignore +++ b/internal/sdk/.gitignore @@ -1,2 +1,7 @@ +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.env +.env.local # .gitignore .speakeasy/reports diff --git a/internal/sdk/docs/models/operations/option.md b/internal/sdk/docs/models/operations/option.md new file mode 100644 index 0000000..35d8a1e --- /dev/null +++ b/internal/sdk/docs/models/operations/option.md @@ -0,0 +1,37 @@ +## Options + +### WithServerURL + +WithServerURL allows providing an alternative server URL. + +```go +operations.WithServerURL("http://api.example.com") +``` + +## WithTemplatedServerURL + +WithTemplatedServerURL allows providing an alternative server URL with templated parameters. + +```go +operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ + "host": "api.example.com", + "port": "8080", +}) +``` + +### WithRetries + +WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. + +```go +operations.WithRetries(retry.Config{ + Strategy: "backoff", + Backoff: retry.BackoffStrategy{ + InitialInterval: 500 * time.Millisecond, + MaxInterval: 60 * time.Second, + Exponent: 1.5, + MaxElapsedTime: 5 * time.Minute, + }, + RetryConnectionErrors: true, +}) +``` \ No newline at end of file diff --git a/internal/sdk/group.go b/internal/sdk/group.go index bf8bdd2..58c225b 100644 --- a/internal/sdk/group.go +++ b/internal/sdk/group.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/config" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/errors" @@ -18,25 +19,22 @@ import ( // Group - User Groups type Group struct { - sdkConfiguration sdkConfiguration + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } -func newGroup(sdkConfig sdkConfiguration) *Group { +func newGroup(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *Group { return &Group{ + rootSDK: rootSDK, sdkConfiguration: sdkConfig, + hooks: hooks, } } // GetGroups - getGroups // Lists groups in organizations you have access to func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsRequest, opts ...operations.Option) (*operations.GetGroupsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getGroups", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -60,6 +58,16 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getGroups", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -116,15 +124,17 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -141,7 +151,7 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -149,13 +159,13 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -168,17 +178,17 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -228,13 +238,6 @@ func (s *Group) GetGroups(ctx context.Context, request operations.GetGroupsReque // CreateGroup - createGroup // Create a new group func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, opts ...operations.Option) (*operations.CreateGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "createGroup", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -258,6 +261,15 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createGroup", + 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 @@ -318,15 +330,17 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -343,7 +357,7 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -351,13 +365,13 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -370,17 +384,17 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -430,13 +444,6 @@ func (s *Group) CreateGroup(ctx context.Context, request *shared.CreateGroupReq, // GetGroup - getGroup // Get group by id func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest, opts ...operations.Option) (*operations.GetGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getGroup", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -460,6 +467,16 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getGroup", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -516,15 +533,17 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -541,7 +560,7 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -549,13 +568,13 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -568,17 +587,17 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -629,13 +648,6 @@ func (s *Group) GetGroup(ctx context.Context, request operations.GetGroupRequest // UpdateGroup - updateGroup // Update group by id func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupRequest, opts ...operations.Option) (*operations.UpdateGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateGroup", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -659,6 +671,15 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateGroup", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "UpdateGroupReq", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -719,15 +740,17 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -744,7 +767,7 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -752,13 +775,13 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -771,17 +794,17 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -832,13 +855,6 @@ func (s *Group) UpdateGroup(ctx context.Context, request operations.UpdateGroupR // DeleteGroup - deleteGroup // Delete group by id func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupRequest, opts ...operations.Option) (*operations.DeleteGroupResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteGroup", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -862,6 +878,16 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteGroup", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -914,15 +940,17 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -939,7 +967,7 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -947,13 +975,13 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -966,17 +994,17 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1006,13 +1034,6 @@ func (s *Group) DeleteGroup(ctx context.Context, request operations.DeleteGroupR // AdvanceUserAssignment - advanceUserAssignment // Advance user assignment to next user in line func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.AdvanceUserAssignmentRequest, opts ...operations.Option) (*operations.AdvanceUserAssignmentResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "advanceUserAssignment", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1036,6 +1057,16 @@ func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.Ad return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "advanceUserAssignment", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1088,15 +1119,17 @@ func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.Ad "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1113,7 +1146,7 @@ func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.Ad err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1121,13 +1154,13 @@ func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.Ad if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1140,17 +1173,17 @@ func (s *Group) AdvanceUserAssignment(ctx context.Context, request operations.Ad err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } diff --git a/internal/sdk/internal/config/sdkconfiguration.go b/internal/sdk/internal/config/sdkconfiguration.go new file mode 100644 index 0000000..d3c9e89 --- /dev/null +++ b/internal/sdk/internal/config/sdkconfiguration.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package config + +import ( + "context" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/retry" + "net/http" + "time" +) + +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type SDKConfiguration struct { + Client HTTPClient + Security func(context.Context) (interface{}, error) + ServerURL string + ServerIndex int + ServerList []string + UserAgent string + RetryConfig *retry.Config + Timeout *time.Duration +} + +func (c *SDKConfiguration) GetServerDetails() (string, map[string]string) { + if c.ServerURL != "" { + return c.ServerURL, nil + } + + return c.ServerList[c.ServerIndex], nil +} diff --git a/internal/sdk/internal/hooks/hooks.go b/internal/sdk/internal/hooks/hooks.go index 8ea491a..61ceb93 100644 --- a/internal/sdk/internal/hooks/hooks.go +++ b/internal/sdk/internal/hooks/hooks.go @@ -5,6 +5,7 @@ package hooks import ( "context" "errors" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/config" "net/http" ) @@ -24,10 +25,13 @@ type HTTPClient interface { } type HookContext struct { - Context context.Context - OperationID string - OAuth2Scopes []string - SecuritySource func(context.Context) (interface{}, error) + SDK any + SDKConfiguration config.SDKConfiguration + BaseURL string + Context context.Context + OperationID string + OAuth2Scopes []string + SecuritySource func(context.Context) (interface{}, error) } type BeforeRequestContext struct { @@ -70,6 +74,11 @@ type Hooks struct { afterErrorHook []afterErrorHook } +var _ sdkInitHook = (*Hooks)(nil) +var _ beforeRequestHook = (*Hooks)(nil) +var _ afterSuccessHook = (*Hooks)(nil) +var _ afterErrorHook = (*Hooks)(nil) + func New() *Hooks { h := &Hooks{ sdkInitHooks: []sdkInitHook{}, diff --git a/internal/sdk/internal/utils/form.go b/internal/sdk/internal/utils/form.go index 15baeab..c223cf0 100644 --- a/internal/sdk/internal/utils/form.go +++ b/internal/sdk/internal/utils/form.go @@ -10,16 +10,19 @@ import ( "strings" "time" - "github.com/ericlagergren/decimal" - + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/types" ) -func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string, getFieldName func(reflect.StructField) string) url.Values { formValues := url.Values{} if isNil(objType, objValue) { + if defaultValue != nil { + formValues.Add(paramName, *defaultValue) + } + return formValues } @@ -37,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 @@ -60,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()))) } @@ -71,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..1b1692a 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-usergroup/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 fdd609a..c108638 100644 --- a/internal/sdk/internal/utils/json.go +++ b/internal/sdk/internal/utils/json.go @@ -5,6 +5,7 @@ package utils import ( "bytes" "encoding/json" + "errors" "fmt" "math/big" "reflect" @@ -14,8 +15,6 @@ import ( "unsafe" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/types" - - "github.com/ericlagergren/decimal" ) func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { @@ -40,21 +39,30 @@ func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, e fieldName := field.Name omitEmpty := false + omitZero := false jsonTag := field.Tag.Get("json") if jsonTag != "" { for _, tag := range strings.Split(jsonTag, ",") { if tag == "omitempty" { omitEmpty = true + } else if tag == "omitzero" { + omitZero = true } else { fieldName = tag } } } - if isNil(field.Type, fieldVal) && field.Tag.Get("const") == "" { - if omitEmpty { + if (omitEmpty || omitZero) && field.Tag.Get("const") == "" { + // Both omitempty and omitzero skip zero values (including nil) + if isNil(field.Type, fieldVal) { + continue + } + + if omitZero && fieldVal.IsZero() { continue } + } if !field.IsExported() && field.Tag.Get("const") == "" { @@ -114,9 +122,9 @@ func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, e } } -func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, disallowUnknownFields bool) error { +func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, requiredFields []string) error { if reflect.TypeOf(v).Kind() != reflect.Ptr { - return fmt.Errorf("v must be a pointer") + return errors.New("v must be a pointer") } typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) @@ -124,19 +132,25 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool switch { case isModelType(typ): if topLevel || bytes.Equal(b, []byte("null")) { - d := json.NewDecoder(bytes.NewReader(b)) - if disallowUnknownFields { - d.DisallowUnknownFields() - } - return d.Decode(v) + return json.Unmarshal(b, v) } - var unmarhsaled map[string]json.RawMessage + var unmarshaled map[string]json.RawMessage - if err := json.Unmarshal(b, &unmarhsaled); err != nil { + if err := json.Unmarshal(b, &unmarshaled); err != nil { return err } + missingFields := []string{} + for _, requiredField := range requiredFields { + if _, ok := unmarshaled[requiredField]; !ok { + missingFields = append(missingFields, requiredField) + } + } + if len(missingFields) > 0 { + return fmt.Errorf("missing required fields: %s", strings.Join(missingFields, ", ")) + } + var additionalPropertiesField *reflect.StructField var additionalPropertiesValue *reflect.Value @@ -149,7 +163,7 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool jsonTag := field.Tag.Get("json") if jsonTag != "" { for _, tag := range strings.Split(jsonTag, ",") { - if tag != "omitempty" { + if tag != "omitempty" && tag != "omitzero" { fieldName = tag } } @@ -163,7 +177,7 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool // If we receive a value for a const field ignore it but mark it as unmarshaled if field.Tag.Get("const") != "" { - if r, ok := unmarhsaled[fieldName]; ok { + if r, ok := unmarshaled[fieldName]; ok { val := string(r) if strings.HasPrefix(val, `"`) && strings.HasSuffix(val, `"`) { @@ -178,40 +192,36 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool return fmt.Errorf("const field `%s` does not match expected value `%s` got `%s`", fieldName, constValue, val) } - delete(unmarhsaled, fieldName) + delete(unmarshaled, fieldName) } } else if !field.IsExported() { continue } - value, ok := unmarhsaled[fieldName] + value, ok := unmarshaled[fieldName] if !ok { - defaultTag := field.Tag.Get("default") - if defaultTag != "" { + defaultTag, defaultOk := field.Tag.Lookup("default") + if defaultOk { value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) ok = true } } else { - delete(unmarhsaled, fieldName) + delete(unmarshaled, fieldName) } if ok { - if err := unmarshalValue(value, fieldVal, field.Tag, disallowUnknownFields); err != nil { + if err := unmarshalValue(value, fieldVal, field.Tag); err != nil { return err } } } - keys := make([]string, 0, len(unmarhsaled)) - for k := range unmarhsaled { + keys := make([]string, 0, len(unmarshaled)) + for k := range unmarshaled { keys = append(keys, k) } if len(keys) > 0 { - if disallowUnknownFields && (additionalPropertiesField == nil || additionalPropertiesValue == nil) { - return fmt.Errorf("unknown fields: %v", keys) - } - if additionalPropertiesField != nil && additionalPropertiesValue != nil { typeOfMap := additionalPropertiesField.Type if additionalPropertiesValue.Type().Kind() == reflect.Interface { @@ -222,10 +232,10 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool mapValue := reflect.MakeMap(typeOfMap) - for key, value := range unmarhsaled { + for key, value := range unmarshaled { val := reflect.New(typeOfMap.Elem()) - if err := unmarshalValue(value, val, additionalPropertiesField.Tag, disallowUnknownFields); err != nil { + if err := unmarshalValue(value, val, additionalPropertiesField.Tag); err != nil { return err } @@ -244,7 +254,7 @@ func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool } } default: - return unmarshalValue(b, reflect.ValueOf(v), tag, disallowUnknownFields) + return unmarshalValue(b, reflect.ValueOf(v), tag) } return nil @@ -257,8 +267,8 @@ func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) } if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { - defaultTag := tag.Get("default") - if defaultTag != "" { + defaultTag, ok := tag.Lookup("default") + if ok { return handleDefaultConstValue(defaultTag, v, tag), nil } @@ -284,6 +294,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() { @@ -337,17 +352,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 - } } } @@ -378,11 +382,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: @@ -394,7 +393,7 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc return []byte(tagValue) } -func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTag, disallowUnknownFields bool) error { +func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTag) error { if bytes.Equal(value, []byte("null")) { if v.CanAddr() { return json.Unmarshal(value, v.Addr().Interface()) @@ -466,18 +465,18 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa } } - var unmarhsaled map[string]json.RawMessage + var unmarshaled map[string]json.RawMessage - if err := json.Unmarshal(value, &unmarhsaled); err != nil { + if err := json.Unmarshal(value, &unmarshaled); err != nil { return err } m := reflect.MakeMap(typ) - for k, value := range unmarhsaled { + for k, value := range unmarshaled { itemVal := reflect.New(typ.Elem()) - if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + if err := unmarshalValue(value, itemVal, tag); err != nil { return err } @@ -498,7 +497,7 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa for index, value := range unmarshaled { itemVal := reflect.New(typ.Elem()) - if err := unmarshalValue(value, itemVal, tag, disallowUnknownFields); err != nil { + if err := unmarshalValue(value, itemVal, tag); err != nil { return err } @@ -563,27 +562,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 @@ -616,11 +594,7 @@ func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTa val = v.Interface() } - d := json.NewDecoder(bytes.NewReader(value)) - if disallowUnknownFields { - d.DisallowUnknownFields() - } - return d.Decode(val) + return json.Unmarshal(value, val) } func dereferencePointers(typ reflect.Type, val reflect.Value) (reflect.Type, reflect.Value) { @@ -652,8 +626,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 } @@ -673,3 +645,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 d403ca8..73eecc1 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-usergroup/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-usergroup/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 09671dd..ee2d03c 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-usergroup/internal/sdk/optionalnullable" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/types" ) @@ -43,10 +42,13 @@ func PopulateQueryParams(_ context.Context, req *http.Request, queryParams inter } func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { - queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), reflect.ValueOf(queryParams)) + queryParamsVal := reflect.ValueOf(queryParams) + if queryParamsVal.Kind() == reflect.Pointer && queryParamsVal.IsNil() { + return nil, nil + } + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), queryParamsVal) globalsAlreadyPopulated := []string{} - for i := 0; i < queryParamsStructType.NumField(); i++ { fieldType := queryParamsStructType.Field(i) valType := queryParamsValType.Field(i) @@ -65,6 +67,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur continue } + constValue := parseConstTag(fieldType) + if constValue != nil { + values.Add(qpTag.ParamName, *constValue) + continue + } + + defaultValue := parseDefaultTag(fieldType) + if globals != nil { var globalFound bool fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) @@ -91,14 +101,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur } } case "form": - vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + vals := populateFormParams(qpTag, fieldType.Type, valType, ",", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "pipeDelimited": - vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + vals := populateFormParams(qpTag, fieldType.Type, valType, "|", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) @@ -149,6 +159,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) @@ -227,7 +247,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 @@ -240,8 +260,8 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru } } -func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { - return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, defaultValue, func(fieldType reflect.StructField) string { qpTag := parseQueryParamTag(fieldType) if qpTag == nil { return "" diff --git a/internal/sdk/internal/utils/requestbody.go b/internal/sdk/internal/utils/requestbody.go index 78479c6..d3a568e 100644 --- a/internal/sdk/internal/utils/requestbody.go +++ b/internal/sdk/internal/utils/requestbody.go @@ -7,10 +7,15 @@ import ( "context" "fmt" "io" + "mime" "mime/multipart" + "net/textproto" "net/url" + "path/filepath" "reflect" "regexp" + + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/optionalnullable" ) const ( @@ -166,9 +171,21 @@ func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { tag := parseMultipartFormTag(field) if tag.File { - if err := encodeMultipartFormDataFile(writer, tag.Name, fieldType, valType); err != nil { - writer.Close() - return "", err + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + for i := 0; i < valType.Len(); i++ { + arrayVal := valType.Index(i) + + if err := encodeMultipartFormDataFile(writer, tag.Name+"[]", arrayVal.Type(), arrayVal); err != nil { + writer.Close() + return "", err + } + } + default: + if err := encodeMultipartFormDataFile(writer, tag.Name, fieldType, valType); err != nil { + writer.Close() + return "", err + } } } else if tag.JSON { jw, err := writer.CreateFormField(tag.Name) @@ -243,7 +260,18 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldName string, fieldTyp return fmt.Errorf("invalid multipart/form-data file") } - fw, err := w.CreateFormFile(fieldName, fileName) + // Detect content type based on file extension + contentType := mime.TypeByExtension(filepath.Ext(fileName)) + if contentType == "" { + contentType = "application/octet-stream" + } + + // Create multipart header with proper content type + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%s"; filename="%s"`, fieldName, fileName)) + h.Set("Content-Type", contentType) + + fw, err := w.CreatePart(h) if err != nil { return err } @@ -251,6 +279,11 @@ func encodeMultipartFormDataFile(w *multipart.Writer, fieldName string, fieldTyp return err } + // Reset seek position to 0 if the reader supports seeking + if seeker, ok := reader.(io.Seeker); ok { + _, _ = seeker.Seek(0, io.SeekStart) + } + return nil } @@ -292,7 +325,7 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { switch tag.Style { // TODO: support other styles case "form": - values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", nil, func(sf reflect.StructField) string { tag := parseFormTag(field) if tag == nil { return "" @@ -309,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/retries.go b/internal/sdk/internal/utils/retries.go index df424b7..ff01d2c 100644 --- a/internal/sdk/internal/utils/retries.go +++ b/internal/sdk/internal/utils/retries.go @@ -7,10 +7,12 @@ import ( "errors" "fmt" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/retry" + "io" "math" "math/rand" "net/http" "net/url" + "slices" "strconv" "strings" "time" @@ -27,6 +29,17 @@ type Retries struct { StatusCodes []string } +var ( + // IETF RFC 7231 4.2 safe and idempotent HTTP methods for connection retries + idempotentHTTPMethods = []string{ + http.MethodDelete, + http.MethodGet, + http.MethodHead, + http.MethodOptions, + http.MethodPut, + } +) + func Retry(ctx context.Context, r Retries, operation func() (*http.Response, error)) (*http.Response, error) { switch r.Config.Strategy { case "backoff": @@ -49,11 +62,48 @@ func Retry(ctx context.Context, r Retries, operation func() (*http.Response, err res, err := operation() if err != nil { + if !r.Config.RetryConnectionErrors { + return retry.Permanent(err) + } + + var httpMethod string + + // Use http.Request method if available + if res != nil && res.Request != nil { + httpMethod = res.Request.Method + } + + isIdempotentHTTPMethod := slices.Contains(idempotentHTTPMethods, httpMethod) urlError := new(url.Error) + if errors.As(err, &urlError) { - if (urlError.Temporary() || urlError.Timeout()) && r.Config.RetryConnectionErrors { + if urlError.Temporary() || urlError.Timeout() { return err } + + // In certain error cases, the http.Request may not have + // been populated, so use url.Error.Op which only has its + // first character capitalized from the original request + // HTTP method. + if httpMethod == "" { + httpMethod = strings.ToUpper(urlError.Op) + } + + isIdempotentHTTPMethod = slices.Contains(idempotentHTTPMethods, httpMethod) + + // Connection closed + if errors.Is(urlError.Err, io.EOF) && isIdempotentHTTPMethod { + return err + } + } + + // syscall detection is not available on every platform, so + // fallback to best effort string detection. + isBrokenPipeError := strings.Contains(err.Error(), "broken pipe") + isConnectionResetError := strings.Contains(err.Error(), "connection reset") + + if (isBrokenPipeError || isConnectionResetError) && isIdempotentHTTPMethod { + return err } return retry.Permanent(err) diff --git a/internal/sdk/internal/utils/utils.go b/internal/sdk/internal/utils/utils.go index 031a71a..0415b53 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 ( @@ -40,8 +38,8 @@ func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) if err != nil { return fmt.Errorf("error reading response body: %w", err) } - if err := UnmarshalJSON(data, out, reflect.StructTag(tag), true, false); err != nil { - return fmt.Errorf("error unmarshalling json response body: %w", err) + if err := UnmarshalJSON(data, out, reflect.StructTag(tag), true, nil); err != nil { + return fmt.Errorf("error unmarshaling json response body: %w", err) } return nil @@ -96,6 +94,26 @@ func AsSecuritySource(security interface{}) func(context.Context) (interface{}, } } +func parseConstTag(field reflect.StructField) *string { + value := field.Tag.Get("const") + + if value == "" { + return nil + } + + return &value +} + +func parseDefaultTag(field reflect.StructField) *string { + value := field.Tag.Get("default") + + if value == "" { + return nil + } + + return &value +} + func parseStructTag(tagKey string, field reflect.StructField) map[string]string { tag := field.Tag.Get(tagKey) if tag == "" { @@ -163,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) } @@ -225,6 +241,21 @@ func isNil(typ reflect.Type, val reflect.Value) bool { return false } +func isEmptyContainer(typ reflect.Type, val reflect.Value) bool { + if isNil(typ, val) { + return true + } + + switch typ.Kind() { + case reflect.Slice, reflect.Array: + return val.Len() == 0 + case reflect.Map: + return val.Len() == 0 + default: + return false + } +} + func contains(arr []string, str string) bool { for _, a := range arr { if a == str { diff --git a/internal/sdk/models/operations/activateuser.go b/internal/sdk/models/operations/activateuser.go index 1ef6ba3..bafe6e6 100644 --- a/internal/sdk/models/operations/activateuser.go +++ b/internal/sdk/models/operations/activateuser.go @@ -13,18 +13,18 @@ type ActivateUserRequest struct { UserActivationPayload *shared.UserActivationPayload `request:"mediaType=application/json"` } -func (o *ActivateUserRequest) GetToken() string { - if o == nil { +func (a *ActivateUserRequest) GetToken() string { + if a == nil { return "" } - return o.Token + return a.Token } -func (o *ActivateUserRequest) GetUserActivationPayload() *shared.UserActivationPayload { - if o == nil { +func (a *ActivateUserRequest) GetUserActivationPayload() *shared.UserActivationPayload { + if a == nil { return nil } - return o.UserActivationPayload + return a.UserActivationPayload } type ActivateUserResponse struct { @@ -36,23 +36,23 @@ type ActivateUserResponse struct { RawResponse *http.Response } -func (o *ActivateUserResponse) GetContentType() string { - if o == nil { +func (a *ActivateUserResponse) GetContentType() string { + if a == nil { return "" } - return o.ContentType + return a.ContentType } -func (o *ActivateUserResponse) GetStatusCode() int { - if o == nil { +func (a *ActivateUserResponse) GetStatusCode() int { + if a == nil { return 0 } - return o.StatusCode + return a.StatusCode } -func (o *ActivateUserResponse) GetRawResponse() *http.Response { - if o == nil { +func (a *ActivateUserResponse) GetRawResponse() *http.Response { + if a == nil { return nil } - return o.RawResponse + return a.RawResponse } diff --git a/internal/sdk/models/operations/advanceuserassignment.go b/internal/sdk/models/operations/advanceuserassignment.go index a4ee2a6..9053f40 100644 --- a/internal/sdk/models/operations/advanceuserassignment.go +++ b/internal/sdk/models/operations/advanceuserassignment.go @@ -12,11 +12,11 @@ type AdvanceUserAssignmentRequest struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *AdvanceUserAssignmentRequest) GetID() string { - if o == nil { +func (a *AdvanceUserAssignmentRequest) GetID() string { + if a == nil { return "" } - return o.ID + return a.ID } type AdvanceUserAssignmentResponse struct { @@ -30,30 +30,30 @@ type AdvanceUserAssignmentResponse struct { Group *shared.Group } -func (o *AdvanceUserAssignmentResponse) GetContentType() string { - if o == nil { +func (a *AdvanceUserAssignmentResponse) GetContentType() string { + if a == nil { return "" } - return o.ContentType + return a.ContentType } -func (o *AdvanceUserAssignmentResponse) GetStatusCode() int { - if o == nil { +func (a *AdvanceUserAssignmentResponse) GetStatusCode() int { + if a == nil { return 0 } - return o.StatusCode + return a.StatusCode } -func (o *AdvanceUserAssignmentResponse) GetRawResponse() *http.Response { - if o == nil { +func (a *AdvanceUserAssignmentResponse) GetRawResponse() *http.Response { + if a == nil { return nil } - return o.RawResponse + return a.RawResponse } -func (o *AdvanceUserAssignmentResponse) GetGroup() *shared.Group { - if o == nil { +func (a *AdvanceUserAssignmentResponse) GetGroup() *shared.Group { + if a == nil { return nil } - return o.Group + return a.Group } diff --git a/internal/sdk/models/operations/checkinvitetoken.go b/internal/sdk/models/operations/checkinvitetoken.go index 7cc20fa..192ad8d 100644 --- a/internal/sdk/models/operations/checkinvitetoken.go +++ b/internal/sdk/models/operations/checkinvitetoken.go @@ -11,11 +11,11 @@ type CheckInviteTokenRequest struct { Token string `queryParam:"style=form,explode=true,name=token"` } -func (o *CheckInviteTokenRequest) GetToken() string { - if o == nil { +func (c *CheckInviteTokenRequest) GetToken() string { + if c == nil { return "" } - return o.Token + return c.Token } // CheckInviteTokenResponseBody - Invite token found @@ -34,46 +34,46 @@ type CheckInviteTokenResponseBody struct { InviteePrimaryOrgID *string `json:"invitee_primary_org_id,omitempty"` } -func (o *CheckInviteTokenResponseBody) GetInvitationOrgID() string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInvitationOrgID() string { + if c == nil { return "" } - return o.InvitationOrgID + return c.InvitationOrgID } -func (o *CheckInviteTokenResponseBody) GetInvitationOrgName() string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInvitationOrgName() string { + if c == nil { return "" } - return o.InvitationOrgName + return c.InvitationOrgName } -func (o *CheckInviteTokenResponseBody) GetInvitationOrgLogoURL() *string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInvitationOrgLogoURL() *string { + if c == nil { return nil } - return o.InvitationOrgLogoURL + return c.InvitationOrgLogoURL } -func (o *CheckInviteTokenResponseBody) GetInvitationOrgLogoThumbnailURL() *string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInvitationOrgLogoThumbnailURL() *string { + if c == nil { return nil } - return o.InvitationOrgLogoThumbnailURL + return c.InvitationOrgLogoThumbnailURL } -func (o *CheckInviteTokenResponseBody) GetInviteeUserID() string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInviteeUserID() string { + if c == nil { return "" } - return o.InviteeUserID + return c.InviteeUserID } -func (o *CheckInviteTokenResponseBody) GetInviteePrimaryOrgID() *string { - if o == nil { +func (c *CheckInviteTokenResponseBody) GetInviteePrimaryOrgID() *string { + if c == nil { return nil } - return o.InviteePrimaryOrgID + return c.InviteePrimaryOrgID } type CheckInviteTokenResponse struct { @@ -87,30 +87,30 @@ type CheckInviteTokenResponse struct { Object *CheckInviteTokenResponseBody } -func (o *CheckInviteTokenResponse) GetContentType() string { - if o == nil { +func (c *CheckInviteTokenResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *CheckInviteTokenResponse) GetStatusCode() int { - if o == nil { +func (c *CheckInviteTokenResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *CheckInviteTokenResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CheckInviteTokenResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } -func (o *CheckInviteTokenResponse) GetObject() *CheckInviteTokenResponseBody { - if o == nil { +func (c *CheckInviteTokenResponse) GetObject() *CheckInviteTokenResponseBody { + if c == nil { return nil } - return o.Object + return c.Object } diff --git a/internal/sdk/models/operations/creategroup.go b/internal/sdk/models/operations/creategroup.go index bb6d2d0..39fd10a 100644 --- a/internal/sdk/models/operations/creategroup.go +++ b/internal/sdk/models/operations/creategroup.go @@ -18,30 +18,30 @@ type CreateGroupResponse struct { Group *shared.Group } -func (o *CreateGroupResponse) GetContentType() string { - if o == nil { +func (c *CreateGroupResponse) GetContentType() string { + if c == nil { return "" } - return o.ContentType + return c.ContentType } -func (o *CreateGroupResponse) GetStatusCode() int { - if o == nil { +func (c *CreateGroupResponse) GetStatusCode() int { + if c == nil { return 0 } - return o.StatusCode + return c.StatusCode } -func (o *CreateGroupResponse) GetRawResponse() *http.Response { - if o == nil { +func (c *CreateGroupResponse) GetRawResponse() *http.Response { + if c == nil { return nil } - return o.RawResponse + return c.RawResponse } -func (o *CreateGroupResponse) GetGroup() *shared.Group { - if o == nil { +func (c *CreateGroupResponse) GetGroup() *shared.Group { + if c == nil { return nil } - return o.Group + return c.Group } diff --git a/internal/sdk/models/operations/deletegroup.go b/internal/sdk/models/operations/deletegroup.go index 33e4e4d..ada20d1 100644 --- a/internal/sdk/models/operations/deletegroup.go +++ b/internal/sdk/models/operations/deletegroup.go @@ -11,11 +11,11 @@ type DeleteGroupRequest struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *DeleteGroupRequest) GetID() string { - if o == nil { +func (d *DeleteGroupRequest) GetID() string { + if d == nil { return "" } - return o.ID + return d.ID } type DeleteGroupResponse struct { @@ -27,23 +27,23 @@ type DeleteGroupResponse struct { RawResponse *http.Response } -func (o *DeleteGroupResponse) GetContentType() string { - if o == nil { +func (d *DeleteGroupResponse) GetContentType() string { + if d == nil { return "" } - return o.ContentType + return d.ContentType } -func (o *DeleteGroupResponse) GetStatusCode() int { - if o == nil { +func (d *DeleteGroupResponse) GetStatusCode() int { + if d == nil { return 0 } - return o.StatusCode + return d.StatusCode } -func (o *DeleteGroupResponse) GetRawResponse() *http.Response { - if o == nil { +func (d *DeleteGroupResponse) GetRawResponse() *http.Response { + if d == nil { return nil } - return o.RawResponse + return d.RawResponse } diff --git a/internal/sdk/models/operations/deleteuserv2.go b/internal/sdk/models/operations/deleteuserv2.go index cbfc7d2..b978ad4 100644 --- a/internal/sdk/models/operations/deleteuserv2.go +++ b/internal/sdk/models/operations/deleteuserv2.go @@ -12,11 +12,11 @@ type DeleteUserV2Request struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *DeleteUserV2Request) GetID() string { - if o == nil { +func (d *DeleteUserV2Request) GetID() string { + if d == nil { return "" } - return o.ID + return d.ID } type DeleteUserV2Response struct { @@ -30,30 +30,30 @@ type DeleteUserV2Response struct { User *shared.User } -func (o *DeleteUserV2Response) GetContentType() string { - if o == nil { +func (d *DeleteUserV2Response) GetContentType() string { + if d == nil { return "" } - return o.ContentType + return d.ContentType } -func (o *DeleteUserV2Response) GetStatusCode() int { - if o == nil { +func (d *DeleteUserV2Response) GetStatusCode() int { + if d == nil { return 0 } - return o.StatusCode + return d.StatusCode } -func (o *DeleteUserV2Response) GetRawResponse() *http.Response { - if o == nil { +func (d *DeleteUserV2Response) GetRawResponse() *http.Response { + if d == nil { return nil } - return o.RawResponse + return d.RawResponse } -func (o *DeleteUserV2Response) GetUser() *shared.User { - if o == nil { +func (d *DeleteUserV2Response) GetUser() *shared.User { + if d == nil { return nil } - return o.User + return d.User } diff --git a/internal/sdk/models/operations/getgroup.go b/internal/sdk/models/operations/getgroup.go index b8f8e8a..346c9cb 100644 --- a/internal/sdk/models/operations/getgroup.go +++ b/internal/sdk/models/operations/getgroup.go @@ -14,18 +14,18 @@ type GetGroupRequest struct { Hydrate *bool `queryParam:"style=form,explode=true,name=hydrate"` } -func (o *GetGroupRequest) GetID() string { - if o == nil { +func (g *GetGroupRequest) GetID() string { + if g == nil { return "" } - return o.ID + return g.ID } -func (o *GetGroupRequest) GetHydrate() *bool { - if o == nil { +func (g *GetGroupRequest) GetHydrate() *bool { + if g == nil { return nil } - return o.Hydrate + return g.Hydrate } type GetGroupResponse struct { @@ -39,30 +39,30 @@ type GetGroupResponse struct { Group *shared.Group } -func (o *GetGroupResponse) GetContentType() string { - if o == nil { +func (g *GetGroupResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetGroupResponse) GetStatusCode() int { - if o == nil { +func (g *GetGroupResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetGroupResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetGroupResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetGroupResponse) GetGroup() *shared.Group { - if o == nil { +func (g *GetGroupResponse) GetGroup() *shared.Group { + if g == nil { return nil } - return o.Group + return g.Group } diff --git a/internal/sdk/models/operations/getgroups.go b/internal/sdk/models/operations/getgroups.go index cdbc3ff..1192794 100644 --- a/internal/sdk/models/operations/getgroups.go +++ b/internal/sdk/models/operations/getgroups.go @@ -18,32 +18,32 @@ type GetGroupsRequest struct { Hydrate *bool `queryParam:"style=form,explode=true,name=hydrate"` } -func (o *GetGroupsRequest) GetQuery() *string { - if o == nil { +func (g *GetGroupsRequest) GetQuery() *string { + if g == nil { return nil } - return o.Query + return g.Query } -func (o *GetGroupsRequest) GetLimit() *float64 { - if o == nil { +func (g *GetGroupsRequest) GetLimit() *float64 { + if g == nil { return nil } - return o.Limit + return g.Limit } -func (o *GetGroupsRequest) GetOffset() *float64 { - if o == nil { +func (g *GetGroupsRequest) GetOffset() *float64 { + if g == nil { return nil } - return o.Offset + return g.Offset } -func (o *GetGroupsRequest) GetHydrate() *bool { - if o == nil { +func (g *GetGroupsRequest) GetHydrate() *bool { + if g == nil { return nil } - return o.Hydrate + return g.Hydrate } // GetGroupsResponseBody - List of groups @@ -52,18 +52,18 @@ type GetGroupsResponseBody struct { Groups []shared.Group `json:"groups,omitempty"` } -func (o *GetGroupsResponseBody) GetHits() *float64 { - if o == nil { +func (g *GetGroupsResponseBody) GetHits() *float64 { + if g == nil { return nil } - return o.Hits + return g.Hits } -func (o *GetGroupsResponseBody) GetGroups() []shared.Group { - if o == nil { +func (g *GetGroupsResponseBody) GetGroups() []shared.Group { + if g == nil { return nil } - return o.Groups + return g.Groups } type GetGroupsResponse struct { @@ -77,30 +77,30 @@ type GetGroupsResponse struct { Object *GetGroupsResponseBody } -func (o *GetGroupsResponse) GetContentType() string { - if o == nil { +func (g *GetGroupsResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetGroupsResponse) GetStatusCode() int { - if o == nil { +func (g *GetGroupsResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetGroupsResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetGroupsResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetGroupsResponse) GetObject() *GetGroupsResponseBody { - if o == nil { +func (g *GetGroupsResponse) GetObject() *GetGroupsResponseBody { + if g == nil { return nil } - return o.Object + return g.Object } diff --git a/internal/sdk/models/operations/getgroupsforuser.go b/internal/sdk/models/operations/getgroupsforuser.go index 0ccddc1..b599e46 100644 --- a/internal/sdk/models/operations/getgroupsforuser.go +++ b/internal/sdk/models/operations/getgroupsforuser.go @@ -12,11 +12,11 @@ type GetGroupsForUserRequest struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *GetGroupsForUserRequest) GetID() string { - if o == nil { +func (g *GetGroupsForUserRequest) GetID() string { + if g == nil { return "" } - return o.ID + return g.ID } type GetGroupsForUserResponse struct { @@ -30,30 +30,30 @@ type GetGroupsForUserResponse struct { Groups []shared.Group } -func (o *GetGroupsForUserResponse) GetContentType() string { - if o == nil { +func (g *GetGroupsForUserResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetGroupsForUserResponse) GetStatusCode() int { - if o == nil { +func (g *GetGroupsForUserResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetGroupsForUserResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetGroupsForUserResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetGroupsForUserResponse) GetGroups() []shared.Group { - if o == nil { +func (g *GetGroupsForUserResponse) GetGroups() []shared.Group { + if g == nil { return nil } - return o.Groups + return g.Groups } diff --git a/internal/sdk/models/operations/getme.go b/internal/sdk/models/operations/getme.go index ee7a8bf..547222d 100644 --- a/internal/sdk/models/operations/getme.go +++ b/internal/sdk/models/operations/getme.go @@ -18,30 +18,30 @@ type GetMeResponse struct { User *shared.User } -func (o *GetMeResponse) GetContentType() string { - if o == nil { +func (g *GetMeResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetMeResponse) GetStatusCode() int { - if o == nil { +func (g *GetMeResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetMeResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetMeResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetMeResponse) GetUser() *shared.User { - if o == nil { +func (g *GetMeResponse) GetUser() *shared.User { + if g == nil { return nil } - return o.User + return g.User } diff --git a/internal/sdk/models/operations/getmev2.go b/internal/sdk/models/operations/getmev2.go index 34661e4..a1475a5 100644 --- a/internal/sdk/models/operations/getmev2.go +++ b/internal/sdk/models/operations/getmev2.go @@ -18,30 +18,30 @@ type GetMeV2Response struct { UserV2 *shared.UserV2 } -func (o *GetMeV2Response) GetContentType() string { - if o == nil { +func (g *GetMeV2Response) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetMeV2Response) GetStatusCode() int { - if o == nil { +func (g *GetMeV2Response) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetMeV2Response) GetRawResponse() *http.Response { - if o == nil { +func (g *GetMeV2Response) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetMeV2Response) GetUserV2() *shared.UserV2 { - if o == nil { +func (g *GetMeV2Response) GetUserV2() *shared.UserV2 { + if g == nil { return nil } - return o.UserV2 + return g.UserV2 } diff --git a/internal/sdk/models/operations/getuser.go b/internal/sdk/models/operations/getuser.go index 86f7c82..efbe341 100644 --- a/internal/sdk/models/operations/getuser.go +++ b/internal/sdk/models/operations/getuser.go @@ -12,11 +12,11 @@ type GetUserRequest struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *GetUserRequest) GetID() string { - if o == nil { +func (g *GetUserRequest) GetID() string { + if g == nil { return "" } - return o.ID + return g.ID } type GetUserResponse struct { @@ -30,30 +30,30 @@ type GetUserResponse struct { User *shared.User } -func (o *GetUserResponse) GetContentType() string { - if o == nil { +func (g *GetUserResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetUserResponse) GetStatusCode() int { - if o == nil { +func (g *GetUserResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetUserResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetUserResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetUserResponse) GetUser() *shared.User { - if o == nil { +func (g *GetUserResponse) GetUser() *shared.User { + if g == nil { return nil } - return o.User + return g.User } diff --git a/internal/sdk/models/operations/getuserloginparameters.go b/internal/sdk/models/operations/getuserloginparameters.go index b080675..0052959 100644 --- a/internal/sdk/models/operations/getuserloginparameters.go +++ b/internal/sdk/models/operations/getuserloginparameters.go @@ -12,11 +12,11 @@ type GetUserLoginParametersRequest struct { Username string `pathParam:"style=simple,explode=false,name=username"` } -func (o *GetUserLoginParametersRequest) GetUsername() string { - if o == nil { +func (g *GetUserLoginParametersRequest) GetUsername() string { + if g == nil { return "" } - return o.Username + return g.Username } // GetUserLoginParametersResponseBody - User @@ -24,11 +24,11 @@ type GetUserLoginParametersResponseBody struct { LoginParameters []shared.LoginParameters `json:"login_parameters,omitempty"` } -func (o *GetUserLoginParametersResponseBody) GetLoginParameters() []shared.LoginParameters { - if o == nil { +func (g *GetUserLoginParametersResponseBody) GetLoginParameters() []shared.LoginParameters { + if g == nil { return nil } - return o.LoginParameters + return g.LoginParameters } type GetUserLoginParametersResponse struct { @@ -42,30 +42,30 @@ type GetUserLoginParametersResponse struct { Object *GetUserLoginParametersResponseBody } -func (o *GetUserLoginParametersResponse) GetContentType() string { - if o == nil { +func (g *GetUserLoginParametersResponse) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetUserLoginParametersResponse) GetStatusCode() int { - if o == nil { +func (g *GetUserLoginParametersResponse) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetUserLoginParametersResponse) GetRawResponse() *http.Response { - if o == nil { +func (g *GetUserLoginParametersResponse) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetUserLoginParametersResponse) GetObject() *GetUserLoginParametersResponseBody { - if o == nil { +func (g *GetUserLoginParametersResponse) GetObject() *GetUserLoginParametersResponseBody { + if g == nil { return nil } - return o.Object + return g.Object } diff --git a/internal/sdk/models/operations/getuserloginparametersv2.go b/internal/sdk/models/operations/getuserloginparametersv2.go index 93ae0ab..73dcd4a 100644 --- a/internal/sdk/models/operations/getuserloginparametersv2.go +++ b/internal/sdk/models/operations/getuserloginparametersv2.go @@ -12,11 +12,11 @@ type GetUserLoginParametersV2Request struct { Username string `pathParam:"style=simple,explode=false,name=username"` } -func (o *GetUserLoginParametersV2Request) GetUsername() string { - if o == nil { +func (g *GetUserLoginParametersV2Request) GetUsername() string { + if g == nil { return "" } - return o.Username + return g.Username } // GetUserLoginParametersV2ResponseBody - User @@ -24,11 +24,11 @@ type GetUserLoginParametersV2ResponseBody struct { LoginParameters []shared.LoginParameters `json:"login_parameters,omitempty"` } -func (o *GetUserLoginParametersV2ResponseBody) GetLoginParameters() []shared.LoginParameters { - if o == nil { +func (g *GetUserLoginParametersV2ResponseBody) GetLoginParameters() []shared.LoginParameters { + if g == nil { return nil } - return o.LoginParameters + return g.LoginParameters } type GetUserLoginParametersV2Response struct { @@ -42,30 +42,30 @@ type GetUserLoginParametersV2Response struct { Object *GetUserLoginParametersV2ResponseBody } -func (o *GetUserLoginParametersV2Response) GetContentType() string { - if o == nil { +func (g *GetUserLoginParametersV2Response) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetUserLoginParametersV2Response) GetStatusCode() int { - if o == nil { +func (g *GetUserLoginParametersV2Response) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetUserLoginParametersV2Response) GetRawResponse() *http.Response { - if o == nil { +func (g *GetUserLoginParametersV2Response) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetUserLoginParametersV2Response) GetObject() *GetUserLoginParametersV2ResponseBody { - if o == nil { +func (g *GetUserLoginParametersV2Response) GetObject() *GetUserLoginParametersV2ResponseBody { + if g == nil { return nil } - return o.Object + return g.Object } diff --git a/internal/sdk/models/operations/getuserv2.go b/internal/sdk/models/operations/getuserv2.go index 181702a..ddf0153 100644 --- a/internal/sdk/models/operations/getuserv2.go +++ b/internal/sdk/models/operations/getuserv2.go @@ -12,11 +12,11 @@ type GetUserV2Request struct { ID string `pathParam:"style=simple,explode=false,name=id"` } -func (o *GetUserV2Request) GetID() string { - if o == nil { +func (g *GetUserV2Request) GetID() string { + if g == nil { return "" } - return o.ID + return g.ID } type GetUserV2Response struct { @@ -30,30 +30,30 @@ type GetUserV2Response struct { UserV2 *shared.UserV2 } -func (o *GetUserV2Response) GetContentType() string { - if o == nil { +func (g *GetUserV2Response) GetContentType() string { + if g == nil { return "" } - return o.ContentType + return g.ContentType } -func (o *GetUserV2Response) GetStatusCode() int { - if o == nil { +func (g *GetUserV2Response) GetStatusCode() int { + if g == nil { return 0 } - return o.StatusCode + return g.StatusCode } -func (o *GetUserV2Response) GetRawResponse() *http.Response { - if o == nil { +func (g *GetUserV2Response) GetRawResponse() *http.Response { + if g == nil { return nil } - return o.RawResponse + return g.RawResponse } -func (o *GetUserV2Response) GetUserV2() *shared.UserV2 { - if o == nil { +func (g *GetUserV2Response) GetUserV2() *shared.UserV2 { + if g == nil { return nil } - return o.UserV2 + return g.UserV2 } diff --git a/internal/sdk/models/operations/inviteuser.go b/internal/sdk/models/operations/inviteuser.go index c9a1b17..ffcfb1f 100644 --- a/internal/sdk/models/operations/inviteuser.go +++ b/internal/sdk/models/operations/inviteuser.go @@ -18,30 +18,30 @@ type InviteUserResponse struct { UserV2 *shared.UserV2 } -func (o *InviteUserResponse) GetContentType() string { - if o == nil { +func (i *InviteUserResponse) GetContentType() string { + if i == nil { return "" } - return o.ContentType + return i.ContentType } -func (o *InviteUserResponse) GetStatusCode() int { - if o == nil { +func (i *InviteUserResponse) GetStatusCode() int { + if i == nil { return 0 } - return o.StatusCode + return i.StatusCode } -func (o *InviteUserResponse) GetRawResponse() *http.Response { - if o == nil { +func (i *InviteUserResponse) GetRawResponse() *http.Response { + if i == nil { return nil } - return o.RawResponse + return i.RawResponse } -func (o *InviteUserResponse) GetUserV2() *shared.UserV2 { - if o == nil { +func (i *InviteUserResponse) GetUserV2() *shared.UserV2 { + if i == nil { return nil } - return o.UserV2 + return i.UserV2 } diff --git a/internal/sdk/models/operations/listusers.go b/internal/sdk/models/operations/listusers.go index 90baac6..681542d 100644 --- a/internal/sdk/models/operations/listusers.go +++ b/internal/sdk/models/operations/listusers.go @@ -18,32 +18,32 @@ type ListUsersRequest struct { Offset *float64 `queryParam:"style=form,explode=true,name=offset"` } -func (o *ListUsersRequest) GetOrgIds() []string { - if o == nil { +func (l *ListUsersRequest) GetOrgIds() []string { + if l == nil { return nil } - return o.OrgIds + return l.OrgIds } -func (o *ListUsersRequest) GetQuery() *string { - if o == nil { +func (l *ListUsersRequest) GetQuery() *string { + if l == nil { return nil } - return o.Query + return l.Query } -func (o *ListUsersRequest) GetLimit() *float64 { - if o == nil { +func (l *ListUsersRequest) GetLimit() *float64 { + if l == nil { return nil } - return o.Limit + return l.Limit } -func (o *ListUsersRequest) GetOffset() *float64 { - if o == nil { +func (l *ListUsersRequest) GetOffset() *float64 { + if l == nil { return nil } - return o.Offset + return l.Offset } // ListUsersResponseBody - List of users @@ -51,11 +51,11 @@ type ListUsersResponseBody struct { Users []shared.User `json:"users,omitempty"` } -func (o *ListUsersResponseBody) GetUsers() []shared.User { - if o == nil { +func (l *ListUsersResponseBody) GetUsers() []shared.User { + if l == nil { return nil } - return o.Users + return l.Users } type ListUsersResponse struct { @@ -69,30 +69,30 @@ type ListUsersResponse struct { Object *ListUsersResponseBody } -func (o *ListUsersResponse) GetContentType() string { - if o == nil { +func (l *ListUsersResponse) GetContentType() string { + if l == nil { return "" } - return o.ContentType + return l.ContentType } -func (o *ListUsersResponse) GetStatusCode() int { - if o == nil { +func (l *ListUsersResponse) GetStatusCode() int { + if l == nil { return 0 } - return o.StatusCode + return l.StatusCode } -func (o *ListUsersResponse) GetRawResponse() *http.Response { - if o == nil { +func (l *ListUsersResponse) GetRawResponse() *http.Response { + if l == nil { return nil } - return o.RawResponse + return l.RawResponse } -func (o *ListUsersResponse) GetObject() *ListUsersResponseBody { - if o == nil { +func (l *ListUsersResponse) GetObject() *ListUsersResponseBody { + if l == nil { return nil } - return o.Object + return l.Object } diff --git a/internal/sdk/models/operations/listusersv2.go b/internal/sdk/models/operations/listusersv2.go index 3772691..a0194fb 100644 --- a/internal/sdk/models/operations/listusersv2.go +++ b/internal/sdk/models/operations/listusersv2.go @@ -16,25 +16,25 @@ type ListUsersV2Request struct { Offset *float64 `queryParam:"style=form,explode=true,name=offset"` } -func (o *ListUsersV2Request) GetQuery() *string { - if o == nil { +func (l *ListUsersV2Request) GetQuery() *string { + if l == nil { return nil } - return o.Query + return l.Query } -func (o *ListUsersV2Request) GetLimit() *float64 { - if o == nil { +func (l *ListUsersV2Request) GetLimit() *float64 { + if l == nil { return nil } - return o.Limit + return l.Limit } -func (o *ListUsersV2Request) GetOffset() *float64 { - if o == nil { +func (l *ListUsersV2Request) GetOffset() *float64 { + if l == nil { return nil } - return o.Offset + return l.Offset } // ListUsersV2ResponseBody - List of organization users @@ -42,11 +42,11 @@ type ListUsersV2ResponseBody struct { Results []shared.UserV2 `json:"results,omitempty"` } -func (o *ListUsersV2ResponseBody) GetResults() []shared.UserV2 { - if o == nil { +func (l *ListUsersV2ResponseBody) GetResults() []shared.UserV2 { + if l == nil { return nil } - return o.Results + return l.Results } type ListUsersV2Response struct { @@ -60,30 +60,30 @@ type ListUsersV2Response struct { Object *ListUsersV2ResponseBody } -func (o *ListUsersV2Response) GetContentType() string { - if o == nil { +func (l *ListUsersV2Response) GetContentType() string { + if l == nil { return "" } - return o.ContentType + return l.ContentType } -func (o *ListUsersV2Response) GetStatusCode() int { - if o == nil { +func (l *ListUsersV2Response) GetStatusCode() int { + if l == nil { return 0 } - return o.StatusCode + return l.StatusCode } -func (o *ListUsersV2Response) GetRawResponse() *http.Response { - if o == nil { +func (l *ListUsersV2Response) GetRawResponse() *http.Response { + if l == nil { return nil } - return o.RawResponse + return l.RawResponse } -func (o *ListUsersV2Response) GetObject() *ListUsersV2ResponseBody { - if o == nil { +func (l *ListUsersV2Response) GetObject() *ListUsersV2ResponseBody { + if l == nil { return nil } - return o.Object + return l.Object } diff --git a/internal/sdk/models/operations/rejectinvite.go b/internal/sdk/models/operations/rejectinvite.go index 9533773..13d6f32 100644 --- a/internal/sdk/models/operations/rejectinvite.go +++ b/internal/sdk/models/operations/rejectinvite.go @@ -11,11 +11,11 @@ type RejectInviteRequest struct { Token string `queryParam:"style=form,explode=true,name=token"` } -func (o *RejectInviteRequest) GetToken() string { - if o == nil { +func (r *RejectInviteRequest) GetToken() string { + if r == nil { return "" } - return o.Token + return r.Token } // RejectInviteResponseBody - Rejected invite successfully @@ -23,11 +23,11 @@ type RejectInviteResponseBody struct { Success *bool `json:"success,omitempty"` } -func (o *RejectInviteResponseBody) GetSuccess() *bool { - if o == nil { +func (r *RejectInviteResponseBody) GetSuccess() *bool { + if r == nil { return nil } - return o.Success + return r.Success } type RejectInviteResponse struct { @@ -41,30 +41,30 @@ type RejectInviteResponse struct { Object *RejectInviteResponseBody } -func (o *RejectInviteResponse) GetContentType() string { - if o == nil { +func (r *RejectInviteResponse) GetContentType() string { + if r == nil { return "" } - return o.ContentType + return r.ContentType } -func (o *RejectInviteResponse) GetStatusCode() int { - if o == nil { +func (r *RejectInviteResponse) GetStatusCode() int { + if r == nil { return 0 } - return o.StatusCode + return r.StatusCode } -func (o *RejectInviteResponse) GetRawResponse() *http.Response { - if o == nil { +func (r *RejectInviteResponse) GetRawResponse() *http.Response { + if r == nil { return nil } - return o.RawResponse + return r.RawResponse } -func (o *RejectInviteResponse) GetObject() *RejectInviteResponseBody { - if o == nil { +func (r *RejectInviteResponse) GetObject() *RejectInviteResponseBody { + if r == nil { return nil } - return o.Object + return r.Object } diff --git a/internal/sdk/models/operations/resenduserinvitation.go b/internal/sdk/models/operations/resenduserinvitation.go index 6115f50..1920e3d 100644 --- a/internal/sdk/models/operations/resenduserinvitation.go +++ b/internal/sdk/models/operations/resenduserinvitation.go @@ -49,24 +49,24 @@ func (r ResendUserInvitationRequestBody) MarshalJSON() ([]byte, error) { } func (r *ResendUserInvitationRequestBody) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &r, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { return err } return nil } -func (o *ResendUserInvitationRequestBody) GetEmail() *string { - if o == nil { +func (r *ResendUserInvitationRequestBody) GetEmail() *string { + if r == nil { return nil } - return o.Email + return r.Email } -func (o *ResendUserInvitationRequestBody) GetLanguage() *Language { - if o == nil { +func (r *ResendUserInvitationRequestBody) GetLanguage() *Language { + if r == nil { return nil } - return o.Language + return r.Language } type ResendUserInvitationResponse struct { @@ -80,30 +80,30 @@ type ResendUserInvitationResponse struct { UserV2 *shared.UserV2 } -func (o *ResendUserInvitationResponse) GetContentType() string { - if o == nil { +func (r *ResendUserInvitationResponse) GetContentType() string { + if r == nil { return "" } - return o.ContentType + return r.ContentType } -func (o *ResendUserInvitationResponse) GetStatusCode() int { - if o == nil { +func (r *ResendUserInvitationResponse) GetStatusCode() int { + if r == nil { return 0 } - return o.StatusCode + return r.StatusCode } -func (o *ResendUserInvitationResponse) GetRawResponse() *http.Response { - if o == nil { +func (r *ResendUserInvitationResponse) GetRawResponse() *http.Response { + if r == nil { return nil } - return o.RawResponse + return r.RawResponse } -func (o *ResendUserInvitationResponse) GetUserV2() *shared.UserV2 { - if o == nil { +func (r *ResendUserInvitationResponse) GetUserV2() *shared.UserV2 { + if r == nil { return nil } - return o.UserV2 + return r.UserV2 } diff --git a/internal/sdk/models/operations/signupuser.go b/internal/sdk/models/operations/signupuser.go index 9906b86..14ce735 100644 --- a/internal/sdk/models/operations/signupuser.go +++ b/internal/sdk/models/operations/signupuser.go @@ -13,18 +13,18 @@ type SignUpUserRequest struct { SignupUserPayload *shared.SignupUserPayload `request:"mediaType=application/json"` } -func (o *SignUpUserRequest) GetToken() *string { - if o == nil { +func (s *SignUpUserRequest) GetToken() *string { + if s == nil { return nil } - return o.Token + return s.Token } -func (o *SignUpUserRequest) GetSignupUserPayload() *shared.SignupUserPayload { - if o == nil { +func (s *SignUpUserRequest) GetSignupUserPayload() *shared.SignupUserPayload { + if s == nil { return nil } - return o.SignupUserPayload + return s.SignupUserPayload } // SignUpUserResponseBody - The created user and organization @@ -33,18 +33,18 @@ type SignUpUserResponseBody struct { Organization *shared.Organization `json:"organization,omitempty"` } -func (o *SignUpUserResponseBody) GetUser() *shared.User { - if o == nil { +func (s *SignUpUserResponseBody) GetUser() *shared.User { + if s == nil { return nil } - return o.User + return s.User } -func (o *SignUpUserResponseBody) GetOrganization() *shared.Organization { - if o == nil { +func (s *SignUpUserResponseBody) GetOrganization() *shared.Organization { + if s == nil { return nil } - return o.Organization + return s.Organization } type SignUpUserResponse struct { @@ -58,30 +58,30 @@ type SignUpUserResponse struct { Object *SignUpUserResponseBody } -func (o *SignUpUserResponse) GetContentType() string { - if o == nil { +func (s *SignUpUserResponse) GetContentType() string { + if s == nil { return "" } - return o.ContentType + return s.ContentType } -func (o *SignUpUserResponse) GetStatusCode() int { - if o == nil { +func (s *SignUpUserResponse) GetStatusCode() int { + if s == nil { return 0 } - return o.StatusCode + return s.StatusCode } -func (o *SignUpUserResponse) GetRawResponse() *http.Response { - if o == nil { +func (s *SignUpUserResponse) GetRawResponse() *http.Response { + if s == nil { return nil } - return o.RawResponse + return s.RawResponse } -func (o *SignUpUserResponse) GetObject() *SignUpUserResponseBody { - if o == nil { +func (s *SignUpUserResponse) GetObject() *SignUpUserResponseBody { + if s == nil { return nil } - return o.Object + return s.Object } diff --git a/internal/sdk/models/operations/switchorganization.go b/internal/sdk/models/operations/switchorganization.go index 99d4bed..1af4c10 100644 --- a/internal/sdk/models/operations/switchorganization.go +++ b/internal/sdk/models/operations/switchorganization.go @@ -10,11 +10,11 @@ type SwitchOrganizationRequestBody struct { OrgID string `json:"org_id"` } -func (o *SwitchOrganizationRequestBody) GetOrgID() string { - if o == nil { +func (s *SwitchOrganizationRequestBody) GetOrgID() string { + if s == nil { return "" } - return o.OrgID + return s.OrgID } // SwitchOrganizationResponseBody - A login token for the new organization to be used with CUSTOM_AUTH flow @@ -23,11 +23,11 @@ type SwitchOrganizationResponseBody struct { LoginToken string `json:"login_token"` } -func (o *SwitchOrganizationResponseBody) GetLoginToken() string { - if o == nil { +func (s *SwitchOrganizationResponseBody) GetLoginToken() string { + if s == nil { return "" } - return o.LoginToken + return s.LoginToken } type SwitchOrganizationResponse struct { @@ -41,30 +41,30 @@ type SwitchOrganizationResponse struct { Object *SwitchOrganizationResponseBody } -func (o *SwitchOrganizationResponse) GetContentType() string { - if o == nil { +func (s *SwitchOrganizationResponse) GetContentType() string { + if s == nil { return "" } - return o.ContentType + return s.ContentType } -func (o *SwitchOrganizationResponse) GetStatusCode() int { - if o == nil { +func (s *SwitchOrganizationResponse) GetStatusCode() int { + if s == nil { return 0 } - return o.StatusCode + return s.StatusCode } -func (o *SwitchOrganizationResponse) GetRawResponse() *http.Response { - if o == nil { +func (s *SwitchOrganizationResponse) GetRawResponse() *http.Response { + if s == nil { return nil } - return o.RawResponse + return s.RawResponse } -func (o *SwitchOrganizationResponse) GetObject() *SwitchOrganizationResponseBody { - if o == nil { +func (s *SwitchOrganizationResponse) GetObject() *SwitchOrganizationResponseBody { + if s == nil { return nil } - return o.Object + return s.Object } diff --git a/internal/sdk/models/operations/updategroup.go b/internal/sdk/models/operations/updategroup.go index 8b6ad9d..0a929af 100644 --- a/internal/sdk/models/operations/updategroup.go +++ b/internal/sdk/models/operations/updategroup.go @@ -13,18 +13,18 @@ type UpdateGroupRequest struct { UpdateGroupReq *shared.UpdateGroupReq `request:"mediaType=application/json"` } -func (o *UpdateGroupRequest) GetID() string { - if o == nil { +func (u *UpdateGroupRequest) GetID() string { + if u == nil { return "" } - return o.ID + return u.ID } -func (o *UpdateGroupRequest) GetUpdateGroupReq() *shared.UpdateGroupReq { - if o == nil { +func (u *UpdateGroupRequest) GetUpdateGroupReq() *shared.UpdateGroupReq { + if u == nil { return nil } - return o.UpdateGroupReq + return u.UpdateGroupReq } type UpdateGroupResponse struct { @@ -38,30 +38,30 @@ type UpdateGroupResponse struct { Group *shared.Group } -func (o *UpdateGroupResponse) GetContentType() string { - if o == nil { +func (u *UpdateGroupResponse) GetContentType() string { + if u == nil { return "" } - return o.ContentType + return u.ContentType } -func (o *UpdateGroupResponse) GetStatusCode() int { - if o == nil { +func (u *UpdateGroupResponse) GetStatusCode() int { + if u == nil { return 0 } - return o.StatusCode + return u.StatusCode } -func (o *UpdateGroupResponse) GetRawResponse() *http.Response { - if o == nil { +func (u *UpdateGroupResponse) GetRawResponse() *http.Response { + if u == nil { return nil } - return o.RawResponse + return u.RawResponse } -func (o *UpdateGroupResponse) GetGroup() *shared.Group { - if o == nil { +func (u *UpdateGroupResponse) GetGroup() *shared.Group { + if u == nil { return nil } - return o.Group + return u.Group } diff --git a/internal/sdk/models/operations/updateuserv2.go b/internal/sdk/models/operations/updateuserv2.go index c390fc5..67e642d 100644 --- a/internal/sdk/models/operations/updateuserv2.go +++ b/internal/sdk/models/operations/updateuserv2.go @@ -13,18 +13,18 @@ type UpdateUserV2Request struct { UserV2 *shared.UserV2Input `request:"mediaType=application/json"` } -func (o *UpdateUserV2Request) GetID() string { - if o == nil { +func (u *UpdateUserV2Request) GetID() string { + if u == nil { return "" } - return o.ID + return u.ID } -func (o *UpdateUserV2Request) GetUserV2() *shared.UserV2Input { - if o == nil { +func (u *UpdateUserV2Request) GetUserV2() *shared.UserV2Input { + if u == nil { return nil } - return o.UserV2 + return u.UserV2 } type UpdateUserV2Response struct { @@ -38,30 +38,30 @@ type UpdateUserV2Response struct { UserV2 *shared.UserV2 } -func (o *UpdateUserV2Response) GetContentType() string { - if o == nil { +func (u *UpdateUserV2Response) GetContentType() string { + if u == nil { return "" } - return o.ContentType + return u.ContentType } -func (o *UpdateUserV2Response) GetStatusCode() int { - if o == nil { +func (u *UpdateUserV2Response) GetStatusCode() int { + if u == nil { return 0 } - return o.StatusCode + return u.StatusCode } -func (o *UpdateUserV2Response) GetRawResponse() *http.Response { - if o == nil { +func (u *UpdateUserV2Response) GetRawResponse() *http.Response { + if u == nil { return nil } - return o.RawResponse + return u.RawResponse } -func (o *UpdateUserV2Response) GetUserV2() *shared.UserV2 { - if o == nil { +func (u *UpdateUserV2Response) GetUserV2() *shared.UserV2 { + if u == nil { return nil } - return o.UserV2 + return u.UserV2 } diff --git a/internal/sdk/models/operations/verifyemailwithtoken.go b/internal/sdk/models/operations/verifyemailwithtoken.go index 4fa1243..8fc26f3 100644 --- a/internal/sdk/models/operations/verifyemailwithtoken.go +++ b/internal/sdk/models/operations/verifyemailwithtoken.go @@ -13,18 +13,18 @@ type VerifyEmailWithTokenRequest struct { UserVerificationPayload *shared.UserVerificationPayload `request:"mediaType=application/json"` } -func (o *VerifyEmailWithTokenRequest) GetToken() string { - if o == nil { +func (v *VerifyEmailWithTokenRequest) GetToken() string { + if v == nil { return "" } - return o.Token + return v.Token } -func (o *VerifyEmailWithTokenRequest) GetUserVerificationPayload() *shared.UserVerificationPayload { - if o == nil { +func (v *VerifyEmailWithTokenRequest) GetUserVerificationPayload() *shared.UserVerificationPayload { + if v == nil { return nil } - return o.UserVerificationPayload + return v.UserVerificationPayload } type VerifyEmailWithTokenResponse struct { @@ -36,23 +36,23 @@ type VerifyEmailWithTokenResponse struct { RawResponse *http.Response } -func (o *VerifyEmailWithTokenResponse) GetContentType() string { - if o == nil { +func (v *VerifyEmailWithTokenResponse) GetContentType() string { + if v == nil { return "" } - return o.ContentType + return v.ContentType } -func (o *VerifyEmailWithTokenResponse) GetStatusCode() int { - if o == nil { +func (v *VerifyEmailWithTokenResponse) GetStatusCode() int { + if v == nil { return 0 } - return o.StatusCode + return v.StatusCode } -func (o *VerifyEmailWithTokenResponse) GetRawResponse() *http.Response { - if o == nil { +func (v *VerifyEmailWithTokenResponse) GetRawResponse() *http.Response { + if v == nil { return nil } - return o.RawResponse + return v.RawResponse } diff --git a/internal/sdk/models/shared/cognitodetails.go b/internal/sdk/models/shared/cognitodetails.go index 421e244..501955b 100644 --- a/internal/sdk/models/shared/cognitodetails.go +++ b/internal/sdk/models/shared/cognitodetails.go @@ -9,30 +9,30 @@ type CognitoDetails struct { CognitoUserPoolArn *string `json:"cognito_user_pool_arn,omitempty"` } -func (o *CognitoDetails) GetCognitoRegion() *string { - if o == nil { +func (c *CognitoDetails) GetCognitoRegion() *string { + if c == nil { return nil } - return o.CognitoRegion + return c.CognitoRegion } -func (o *CognitoDetails) GetCognitoUserPoolID() *string { - if o == nil { +func (c *CognitoDetails) GetCognitoUserPoolID() *string { + if c == nil { return nil } - return o.CognitoUserPoolID + return c.CognitoUserPoolID } -func (o *CognitoDetails) GetCognitoUserPoolClientID() *string { - if o == nil { +func (c *CognitoDetails) GetCognitoUserPoolClientID() *string { + if c == nil { return nil } - return o.CognitoUserPoolClientID + return c.CognitoUserPoolClientID } -func (o *CognitoDetails) GetCognitoUserPoolArn() *string { - if o == nil { +func (c *CognitoDetails) GetCognitoUserPoolArn() *string { + if c == nil { return nil } - return o.CognitoUserPoolArn + return c.CognitoUserPoolArn } diff --git a/internal/sdk/models/shared/creategroupreq.go b/internal/sdk/models/shared/creategroupreq.go index 1087652..76a6d8d 100644 --- a/internal/sdk/models/shared/creategroupreq.go +++ b/internal/sdk/models/shared/creategroupreq.go @@ -7,9 +7,9 @@ type CreateGroupReq struct { Name string `json:"name"` } -func (o *CreateGroupReq) GetName() string { - if o == nil { +func (c *CreateGroupReq) GetName() string { + if c == nil { return "" } - return o.Name + return c.Name } diff --git a/internal/sdk/models/shared/group.go b/internal/sdk/models/shared/group.go index d2a1138..a27cba6 100644 --- a/internal/sdk/models/shared/group.go +++ b/internal/sdk/models/shared/group.go @@ -9,16 +9,16 @@ type Group struct { Name string `json:"name"` } -func (o *Group) GetID() string { - if o == nil { +func (g *Group) GetID() string { + if g == nil { return "" } - return o.ID + return g.ID } -func (o *Group) GetName() string { - if o == nil { +func (g *Group) GetName() string { + if g == nil { return "" } - return o.Name + return g.Name } diff --git a/internal/sdk/models/shared/loginparameters.go b/internal/sdk/models/shared/loginparameters.go index a9a47f3..29bf633 100644 --- a/internal/sdk/models/shared/loginparameters.go +++ b/internal/sdk/models/shared/loginparameters.go @@ -37,6 +37,7 @@ type LoginParameters struct { OrganizationID *string `json:"organization_id,omitempty"` OrganizationName *string `json:"organization_name,omitempty"` OrganizationType *string `json:"organization_type,omitempty"` + OrganizationUse *string `json:"organization_use,omitempty"` CognitoRegion *string `json:"cognito_region,omitempty"` CognitoUserPoolID *string `json:"cognito_user_pool_id,omitempty"` CognitoUserPoolClientID *string `json:"cognito_user_pool_client_id,omitempty"` @@ -45,65 +46,72 @@ type LoginParameters struct { OauthResponseType *OauthResponseType `json:"oauth_response_type,omitempty"` } -func (o *LoginParameters) GetOrganizationID() *string { - if o == nil { +func (l *LoginParameters) GetOrganizationID() *string { + if l == nil { return nil } - return o.OrganizationID + return l.OrganizationID } -func (o *LoginParameters) GetOrganizationName() *string { - if o == nil { +func (l *LoginParameters) GetOrganizationName() *string { + if l == nil { return nil } - return o.OrganizationName + return l.OrganizationName } -func (o *LoginParameters) GetOrganizationType() *string { - if o == nil { +func (l *LoginParameters) GetOrganizationType() *string { + if l == nil { return nil } - return o.OrganizationType + return l.OrganizationType } -func (o *LoginParameters) GetCognitoRegion() *string { - if o == nil { +func (l *LoginParameters) GetOrganizationUse() *string { + if l == nil { return nil } - return o.CognitoRegion + return l.OrganizationUse } -func (o *LoginParameters) GetCognitoUserPoolID() *string { - if o == nil { +func (l *LoginParameters) GetCognitoRegion() *string { + if l == nil { return nil } - return o.CognitoUserPoolID + return l.CognitoRegion } -func (o *LoginParameters) GetCognitoUserPoolClientID() *string { - if o == nil { +func (l *LoginParameters) GetCognitoUserPoolID() *string { + if l == nil { return nil } - return o.CognitoUserPoolClientID + return l.CognitoUserPoolID } -func (o *LoginParameters) GetCognitoOauthDomain() *string { - if o == nil { +func (l *LoginParameters) GetCognitoUserPoolClientID() *string { + if l == nil { return nil } - return o.CognitoOauthDomain + return l.CognitoUserPoolClientID } -func (o *LoginParameters) GetCognitoOauthScopes() []string { - if o == nil { +func (l *LoginParameters) GetCognitoOauthDomain() *string { + if l == nil { return nil } - return o.CognitoOauthScopes + return l.CognitoOauthDomain } -func (o *LoginParameters) GetOauthResponseType() *OauthResponseType { - if o == nil { +func (l *LoginParameters) GetCognitoOauthScopes() []string { + if l == nil { return nil } - return o.OauthResponseType + return l.CognitoOauthScopes +} + +func (l *LoginParameters) GetOauthResponseType() *OauthResponseType { + if l == nil { + return nil + } + return l.OauthResponseType } diff --git a/internal/sdk/models/shared/organization.go b/internal/sdk/models/shared/organization.go index 3c7c54e..e532cef 100644 --- a/internal/sdk/models/shared/organization.go +++ b/internal/sdk/models/shared/organization.go @@ -41,39 +41,39 @@ type Address struct { StreetNumber *string `json:"street_number,omitempty"` } -func (o *Address) GetCountry() *string { - if o == nil { +func (a *Address) GetCountry() *string { + if a == nil { return nil } - return o.Country + return a.Country } -func (o *Address) GetCity() *string { - if o == nil { +func (a *Address) GetCity() *string { + if a == nil { return nil } - return o.City + return a.City } -func (o *Address) GetPostalCode() *string { - if o == nil { +func (a *Address) GetPostalCode() *string { + if a == nil { return nil } - return o.PostalCode + return a.PostalCode } -func (o *Address) GetStreet() *string { - if o == nil { +func (a *Address) GetStreet() *string { + if a == nil { return nil } - return o.Street + return a.Street } -func (o *Address) GetStreetNumber() *string { - if o == nil { +func (a *Address) GetStreetNumber() *string { + if a == nil { return nil } - return o.StreetNumber + return a.StreetNumber } type Organization struct { diff --git a/internal/sdk/models/shared/organizationdetail.go b/internal/sdk/models/shared/organizationdetail.go index bbc6f0b..4d0d7ed 100644 --- a/internal/sdk/models/shared/organizationdetail.go +++ b/internal/sdk/models/shared/organizationdetail.go @@ -51,7 +51,7 @@ func (o OrganizationDetail) MarshalJSON() ([]byte, error) { } func (o *OrganizationDetail) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &o, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"type", "name", "pricing_tier", "email"}); err != nil { return err } return nil diff --git a/internal/sdk/models/shared/security.go b/internal/sdk/models/shared/security.go index b2b518e..d8751e6 100644 --- a/internal/sdk/models/shared/security.go +++ b/internal/sdk/models/shared/security.go @@ -6,9 +6,9 @@ type Security struct { EpilotAuth *string `security:"scheme,type=http,subtype=bearer,name=Authorization"` } -func (o *Security) GetEpilotAuth() *string { - if o == nil { +func (s *Security) GetEpilotAuth() *string { + if s == nil { return nil } - return o.EpilotAuth + return s.EpilotAuth } diff --git a/internal/sdk/models/shared/signupuserpayload.go b/internal/sdk/models/shared/signupuserpayload.go index d4a0bdd..09ed7b4 100644 --- a/internal/sdk/models/shared/signupuserpayload.go +++ b/internal/sdk/models/shared/signupuserpayload.go @@ -47,29 +47,29 @@ func (s SignupUserPayload) MarshalJSON() ([]byte, error) { } func (s *SignupUserPayload) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &s, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { return err } return nil } -func (o *SignupUserPayload) GetOrganizationDetail() *OrganizationDetail { - if o == nil { +func (s *SignupUserPayload) GetOrganizationDetail() *OrganizationDetail { + if s == nil { return nil } - return o.OrganizationDetail + return s.OrganizationDetail } -func (o *SignupUserPayload) GetUserDetail() *UserDetail { - if o == nil { +func (s *SignupUserPayload) GetUserDetail() *UserDetail { + if s == nil { return nil } - return o.UserDetail + return s.UserDetail } -func (o *SignupUserPayload) GetLanguage() *Language { - if o == nil { +func (s *SignupUserPayload) GetLanguage() *Language { + if s == nil { return nil } - return o.Language + return s.Language } diff --git a/internal/sdk/models/shared/updategroupreq.go b/internal/sdk/models/shared/updategroupreq.go index b043441..abb9423 100644 --- a/internal/sdk/models/shared/updategroupreq.go +++ b/internal/sdk/models/shared/updategroupreq.go @@ -7,9 +7,9 @@ type UpdateGroupReq struct { Name *string `json:"name,omitempty"` } -func (o *UpdateGroupReq) GetName() *string { - if o == nil { +func (u *UpdateGroupReq) GetName() *string { + if u == nil { return nil } - return o.Name + return u.Name } diff --git a/internal/sdk/models/shared/user.go b/internal/sdk/models/shared/user.go index a44b563..260ca48 100644 --- a/internal/sdk/models/shared/user.go +++ b/internal/sdk/models/shared/user.go @@ -17,31 +17,31 @@ func (i ImageURI) MarshalJSON() ([]byte, error) { } func (i *ImageURI) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &i, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &i, "", false, nil); err != nil { return err } return nil } -func (o *ImageURI) GetOriginal() *string { - if o == nil { +func (i *ImageURI) GetOriginal() *string { + if i == nil { return nil } - return o.Original + return i.Original } -func (o *ImageURI) GetThumbnail32() *string { - if o == nil { +func (i *ImageURI) GetThumbnail32() *string { + if i == nil { return nil } - return o.Thumbnail32 + return i.Thumbnail32 } -func (o *ImageURI) GetAdditionalProperties() any { - if o == nil { +func (i *ImageURI) GetAdditionalProperties() any { + if i == nil { return nil } - return o.AdditionalProperties + return i.AdditionalProperties } type Properties struct { @@ -49,18 +49,18 @@ type Properties struct { Value string `json:"value"` } -func (o *Properties) GetName() string { - if o == nil { +func (p *Properties) GetName() string { + if p == nil { return "" } - return o.Name + return p.Name } -func (o *Properties) GetValue() string { - if o == nil { +func (p *Properties) GetValue() string { + if p == nil { return "" } - return o.Value + return p.Value } type User struct { @@ -82,72 +82,72 @@ type User struct { Properties []Properties `json:"properties"` } -func (o *User) GetID() string { - if o == nil { +func (u *User) GetID() string { + if u == nil { return "" } - return o.ID + return u.ID } -func (o *User) GetOrganizationID() string { - if o == nil { +func (u *User) GetOrganizationID() string { + if u == nil { return "" } - return o.OrganizationID + return u.OrganizationID } -func (o *User) GetEmail() string { - if o == nil { +func (u *User) GetEmail() string { + if u == nil { return "" } - return o.Email + return u.Email } -func (o *User) GetDisplayName() *string { - if o == nil { +func (u *User) GetDisplayName() *string { + if u == nil { return nil } - return o.DisplayName + return u.DisplayName } -func (o *User) GetName() string { - if o == nil { +func (u *User) GetName() string { + if u == nil { return "" } - return o.Name + return u.Name } -func (o *User) GetPreferredLanguage() string { - if o == nil { +func (u *User) GetPreferredLanguage() string { + if u == nil { return "" } - return o.PreferredLanguage + return u.PreferredLanguage } -func (o *User) GetSignature() *string { - if o == nil { +func (u *User) GetSignature() *string { + if u == nil { return nil } - return o.Signature + return u.Signature } -func (o *User) GetRoles() []string { - if o == nil { +func (u *User) GetRoles() []string { + if u == nil { return []string{} } - return o.Roles + return u.Roles } -func (o *User) GetImageURI() *ImageURI { - if o == nil { +func (u *User) GetImageURI() *ImageURI { + if u == nil { return nil } - return o.ImageURI + return u.ImageURI } -func (o *User) GetProperties() []Properties { - if o == nil { +func (u *User) GetProperties() []Properties { + if u == nil { return []Properties{} } - return o.Properties + return u.Properties } diff --git a/internal/sdk/models/shared/useractivationpayload.go b/internal/sdk/models/shared/useractivationpayload.go index 7f60fd1..c6b2853 100644 --- a/internal/sdk/models/shared/useractivationpayload.go +++ b/internal/sdk/models/shared/useractivationpayload.go @@ -9,16 +9,16 @@ type UserActivationPayload struct { Password *string `json:"password,omitempty"` } -func (o *UserActivationPayload) GetDisplayName() *string { - if o == nil { +func (u *UserActivationPayload) GetDisplayName() *string { + if u == nil { return nil } - return o.DisplayName + return u.DisplayName } -func (o *UserActivationPayload) GetPassword() *string { - if o == nil { +func (u *UserActivationPayload) GetPassword() *string { + if u == nil { return nil } - return o.Password + return u.Password } diff --git a/internal/sdk/models/shared/userdetail.go b/internal/sdk/models/shared/userdetail.go index f4057f5..8ea8bac 100644 --- a/internal/sdk/models/shared/userdetail.go +++ b/internal/sdk/models/shared/userdetail.go @@ -9,23 +9,23 @@ type UserDetail struct { Password string `json:"password"` } -func (o *UserDetail) GetFullName() string { - if o == nil { +func (u *UserDetail) GetFullName() string { + if u == nil { return "" } - return o.FullName + return u.FullName } -func (o *UserDetail) GetEmail() string { - if o == nil { +func (u *UserDetail) GetEmail() string { + if u == nil { return "" } - return o.Email + return u.Email } -func (o *UserDetail) GetPassword() string { - if o == nil { +func (u *UserDetail) GetPassword() string { + if u == nil { return "" } - return o.Password + return u.Password } diff --git a/internal/sdk/models/shared/userinvitationpayload.go b/internal/sdk/models/shared/userinvitationpayload.go index c162165..d469988 100644 --- a/internal/sdk/models/shared/userinvitationpayload.go +++ b/internal/sdk/models/shared/userinvitationpayload.go @@ -48,29 +48,29 @@ func (u UserInvitationPayload) MarshalJSON() ([]byte, error) { } func (u *UserInvitationPayload) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &u, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { return err } return nil } -func (o *UserInvitationPayload) GetEmail() *string { - if o == nil { +func (u *UserInvitationPayload) GetEmail() *string { + if u == nil { return nil } - return o.Email + return u.Email } -func (o *UserInvitationPayload) GetLanguage() *UserInvitationPayloadLanguage { - if o == nil { +func (u *UserInvitationPayload) GetLanguage() *UserInvitationPayloadLanguage { + if u == nil { return nil } - return o.Language + return u.Language } -func (o *UserInvitationPayload) GetRoles() []string { - if o == nil { +func (u *UserInvitationPayload) GetRoles() []string { + if u == nil { return nil } - return o.Roles + return u.Roles } diff --git a/internal/sdk/models/shared/userv2.go b/internal/sdk/models/shared/userv2.go index 3e236e2..b73c9ca 100644 --- a/internal/sdk/models/shared/userv2.go +++ b/internal/sdk/models/shared/userv2.go @@ -83,31 +83,31 @@ func (u UserV2ImageURI) MarshalJSON() ([]byte, error) { } func (u *UserV2ImageURI) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &u, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { return err } return nil } -func (o *UserV2ImageURI) GetOriginal() *string { - if o == nil { +func (u *UserV2ImageURI) GetOriginal() *string { + if u == nil { return nil } - return o.Original + return u.Original } -func (o *UserV2ImageURI) GetThumbnail32() *string { - if o == nil { +func (u *UserV2ImageURI) GetThumbnail32() *string { + if u == nil { return nil } - return o.Thumbnail32 + return u.Thumbnail32 } -func (o *UserV2ImageURI) GetAdditionalProperties() any { - if o == nil { +func (u *UserV2ImageURI) GetAdditionalProperties() any { + if u == nil { return nil } - return o.AdditionalProperties + return u.AdditionalProperties } type UserV2Properties struct { @@ -115,18 +115,18 @@ type UserV2Properties struct { Value string `json:"value"` } -func (o *UserV2Properties) GetName() string { - if o == nil { +func (u *UserV2Properties) GetName() string { + if u == nil { return "" } - return o.Name + return u.Name } -func (o *UserV2Properties) GetValue() string { - if o == nil { +func (u *UserV2Properties) GetValue() string { + if u == nil { return "" } - return o.Value + return u.Value } type UserV2 struct { @@ -178,178 +178,178 @@ func (u UserV2) MarshalJSON() ([]byte, error) { } func (u *UserV2) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &u, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { return err } return nil } -func (o *UserV2) GetID() *string { - if o == nil { +func (u *UserV2) GetID() *string { + if u == nil { return nil } - return o.ID + return u.ID } -func (o *UserV2) GetOrganizationID() *string { - if o == nil { +func (u *UserV2) GetOrganizationID() *string { + if u == nil { return nil } - return o.OrganizationID + return u.OrganizationID } -func (o *UserV2) GetCreatedAt() *time.Time { - if o == nil { +func (u *UserV2) GetCreatedAt() *time.Time { + if u == nil { return nil } - return o.CreatedAt + return u.CreatedAt } -func (o *UserV2) GetActivatedAt() *time.Time { - if o == nil { +func (u *UserV2) GetActivatedAt() *time.Time { + if u == nil { return nil } - return o.ActivatedAt + return u.ActivatedAt } -func (o *UserV2) GetDisplayName() *string { - if o == nil { +func (u *UserV2) GetDisplayName() *string { + if u == nil { return nil } - return o.DisplayName + return u.DisplayName } -func (o *UserV2) GetStatus() *Status { - if o == nil { +func (u *UserV2) GetStatus() *Status { + if u == nil { return nil } - return o.Status + return u.Status } -func (o *UserV2) GetEmail() *string { - if o == nil { +func (u *UserV2) GetEmail() *string { + if u == nil { return nil } - return o.Email + return u.Email } -func (o *UserV2) GetDraftEmail() *string { - if o == nil { +func (u *UserV2) GetDraftEmail() *string { + if u == nil { return nil } - return o.DraftEmail + return u.DraftEmail } -func (o *UserV2) GetDepartment() *string { - if o == nil { +func (u *UserV2) GetDepartment() *string { + if u == nil { return nil } - return o.Department + return u.Department } -func (o *UserV2) GetPhone() *string { - if o == nil { +func (u *UserV2) GetPhone() *string { + if u == nil { return nil } - return o.Phone + return u.Phone } -func (o *UserV2) GetSecondaryPhone() *string { - if o == nil { +func (u *UserV2) GetSecondaryPhone() *string { + if u == nil { return nil } - return o.SecondaryPhone + return u.SecondaryPhone } -func (o *UserV2) GetMfaEnabled() *bool { - if o == nil { +func (u *UserV2) GetMfaEnabled() *bool { + if u == nil { return nil } - return o.MfaEnabled + return u.MfaEnabled } -func (o *UserV2) GetPhoneVerified() *bool { - if o == nil { +func (u *UserV2) GetPhoneVerified() *bool { + if u == nil { return nil } - return o.PhoneVerified + return u.PhoneVerified } -func (o *UserV2) GetToken() *string { - if o == nil { +func (u *UserV2) GetToken() *string { + if u == nil { return nil } - return o.Token + return u.Token } -func (o *UserV2) GetSignature() *string { - if o == nil { +func (u *UserV2) GetSignature() *string { + if u == nil { return nil } - return o.Signature + return u.Signature } -func (o *UserV2) GetIsSignatureEnabled() *bool { - if o == nil { +func (u *UserV2) GetIsSignatureEnabled() *bool { + if u == nil { return nil } - return o.IsSignatureEnabled + return u.IsSignatureEnabled } -func (o *UserV2) GetPreferredLanguage() *string { - if o == nil { +func (u *UserV2) GetPreferredLanguage() *string { + if u == nil { return nil } - return o.PreferredLanguage + return u.PreferredLanguage } -func (o *UserV2) GetCustomStartPage() *string { - if o == nil { +func (u *UserV2) GetCustomStartPage() *string { + if u == nil { return nil } - return o.CustomStartPage + return u.CustomStartPage } -func (o *UserV2) GetOverrideReleaseChannel() *OverrideReleaseChannel { - if o == nil { +func (u *UserV2) GetOverrideReleaseChannel() *OverrideReleaseChannel { + if u == nil { return nil } - return o.OverrideReleaseChannel + return u.OverrideReleaseChannel } -func (o *UserV2) GetFeaturePreferences() map[string]any { - if o == nil { +func (u *UserV2) GetFeaturePreferences() map[string]any { + if u == nil { return nil } - return o.FeaturePreferences + return u.FeaturePreferences } -func (o *UserV2) GetImageURI() *UserV2ImageURI { - if o == nil { +func (u *UserV2) GetImageURI() *UserV2ImageURI { + if u == nil { return nil } - return o.ImageURI + return u.ImageURI } -func (o *UserV2) GetFavorites() map[string]any { - if o == nil { +func (u *UserV2) GetFavorites() map[string]any { + if u == nil { return nil } - return o.Favorites + return u.Favorites } -func (o *UserV2) GetEmailNotificationSetting() map[string]any { - if o == nil { +func (u *UserV2) GetEmailNotificationSetting() map[string]any { + if u == nil { return nil } - return o.EmailNotificationSetting + return u.EmailNotificationSetting } -func (o *UserV2) GetProperties() []UserV2Properties { - if o == nil { +func (u *UserV2) GetProperties() []UserV2Properties { + if u == nil { return nil } - return o.Properties + return u.Properties } type UserV2Input struct { @@ -399,169 +399,169 @@ func (u UserV2Input) MarshalJSON() ([]byte, error) { } func (u *UserV2Input) UnmarshalJSON(data []byte) error { - if err := utils.UnmarshalJSON(data, &u, "", false, false); err != nil { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { return err } return nil } -func (o *UserV2Input) GetOrganizationID() *string { - if o == nil { +func (u *UserV2Input) GetOrganizationID() *string { + if u == nil { return nil } - return o.OrganizationID + return u.OrganizationID } -func (o *UserV2Input) GetCreatedAt() *time.Time { - if o == nil { +func (u *UserV2Input) GetCreatedAt() *time.Time { + if u == nil { return nil } - return o.CreatedAt + return u.CreatedAt } -func (o *UserV2Input) GetActivatedAt() *time.Time { - if o == nil { +func (u *UserV2Input) GetActivatedAt() *time.Time { + if u == nil { return nil } - return o.ActivatedAt + return u.ActivatedAt } -func (o *UserV2Input) GetDisplayName() *string { - if o == nil { +func (u *UserV2Input) GetDisplayName() *string { + if u == nil { return nil } - return o.DisplayName + return u.DisplayName } -func (o *UserV2Input) GetStatus() *Status { - if o == nil { +func (u *UserV2Input) GetStatus() *Status { + if u == nil { return nil } - return o.Status + return u.Status } -func (o *UserV2Input) GetEmail() *string { - if o == nil { +func (u *UserV2Input) GetEmail() *string { + if u == nil { return nil } - return o.Email + return u.Email } -func (o *UserV2Input) GetDraftEmail() *string { - if o == nil { +func (u *UserV2Input) GetDraftEmail() *string { + if u == nil { return nil } - return o.DraftEmail + return u.DraftEmail } -func (o *UserV2Input) GetDepartment() *string { - if o == nil { +func (u *UserV2Input) GetDepartment() *string { + if u == nil { return nil } - return o.Department + return u.Department } -func (o *UserV2Input) GetPhone() *string { - if o == nil { +func (u *UserV2Input) GetPhone() *string { + if u == nil { return nil } - return o.Phone + return u.Phone } -func (o *UserV2Input) GetSecondaryPhone() *string { - if o == nil { +func (u *UserV2Input) GetSecondaryPhone() *string { + if u == nil { return nil } - return o.SecondaryPhone + return u.SecondaryPhone } -func (o *UserV2Input) GetMfaEnabled() *bool { - if o == nil { +func (u *UserV2Input) GetMfaEnabled() *bool { + if u == nil { return nil } - return o.MfaEnabled + return u.MfaEnabled } -func (o *UserV2Input) GetPhoneVerified() *bool { - if o == nil { +func (u *UserV2Input) GetPhoneVerified() *bool { + if u == nil { return nil } - return o.PhoneVerified + return u.PhoneVerified } -func (o *UserV2Input) GetToken() *string { - if o == nil { +func (u *UserV2Input) GetToken() *string { + if u == nil { return nil } - return o.Token + return u.Token } -func (o *UserV2Input) GetSignature() *string { - if o == nil { +func (u *UserV2Input) GetSignature() *string { + if u == nil { return nil } - return o.Signature + return u.Signature } -func (o *UserV2Input) GetIsSignatureEnabled() *bool { - if o == nil { +func (u *UserV2Input) GetIsSignatureEnabled() *bool { + if u == nil { return nil } - return o.IsSignatureEnabled + return u.IsSignatureEnabled } -func (o *UserV2Input) GetPreferredLanguage() *string { - if o == nil { +func (u *UserV2Input) GetPreferredLanguage() *string { + if u == nil { return nil } - return o.PreferredLanguage + return u.PreferredLanguage } -func (o *UserV2Input) GetCustomStartPage() *string { - if o == nil { +func (u *UserV2Input) GetCustomStartPage() *string { + if u == nil { return nil } - return o.CustomStartPage + return u.CustomStartPage } -func (o *UserV2Input) GetOverrideReleaseChannel() *OverrideReleaseChannel { - if o == nil { +func (u *UserV2Input) GetOverrideReleaseChannel() *OverrideReleaseChannel { + if u == nil { return nil } - return o.OverrideReleaseChannel + return u.OverrideReleaseChannel } -func (o *UserV2Input) GetFeaturePreferences() map[string]any { - if o == nil { +func (u *UserV2Input) GetFeaturePreferences() map[string]any { + if u == nil { return nil } - return o.FeaturePreferences + return u.FeaturePreferences } -func (o *UserV2Input) GetImageURI() *UserV2ImageURI { - if o == nil { +func (u *UserV2Input) GetImageURI() *UserV2ImageURI { + if u == nil { return nil } - return o.ImageURI + return u.ImageURI } -func (o *UserV2Input) GetFavorites() map[string]any { - if o == nil { +func (u *UserV2Input) GetFavorites() map[string]any { + if u == nil { return nil } - return o.Favorites + return u.Favorites } -func (o *UserV2Input) GetEmailNotificationSetting() map[string]any { - if o == nil { +func (u *UserV2Input) GetEmailNotificationSetting() map[string]any { + if u == nil { return nil } - return o.EmailNotificationSetting + return u.EmailNotificationSetting } -func (o *UserV2Input) GetProperties() []UserV2Properties { - if o == nil { +func (u *UserV2Input) GetProperties() []UserV2Properties { + if u == nil { return nil } - return o.Properties + return u.Properties } diff --git a/internal/sdk/models/shared/userverificationpayload.go b/internal/sdk/models/shared/userverificationpayload.go index ad7f2dd..3c3881a 100644 --- a/internal/sdk/models/shared/userverificationpayload.go +++ b/internal/sdk/models/shared/userverificationpayload.go @@ -7,9 +7,9 @@ type UserVerificationPayload struct { Password *string `json:"password,omitempty"` } -func (o *UserVerificationPayload) GetPassword() *string { - if o == nil { +func (u *UserVerificationPayload) GetPassword() *string { + if u == nil { return nil } - return o.Password + return u.Password } 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/sdk.go b/internal/sdk/sdk.go index 168587e..c9222d6 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -2,9 +2,12 @@ package sdk +// Generated from OpenAPI doc version 2.0.0 and generator version 2.745.2 + import ( "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/config" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/shared" @@ -18,7 +21,7 @@ var ServerList = []string{ "https://user.sls.epilot.io", } -// HTTPClient provides an interface for suplying the SDK with a custom HTTP client +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client type HTTPClient interface { Do(req *http.Request) (*http.Response, error) } @@ -44,31 +47,9 @@ 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 } -type sdkConfiguration struct { - Client HTTPClient - Security func(context.Context) (interface{}, error) - ServerURL string - ServerIndex int - Language string - OpenAPIDocVersion string - SDKVersion string - GenVersion string - UserAgent string - RetryConfig *retry.Config - Hooks *hooks.Hooks - Timeout *time.Duration -} - -func (c *sdkConfiguration) GetServerDetails() (string, map[string]string) { - if c.ServerURL != "" { - return c.ServerURL, nil - } - - return ServerList[c.ServerIndex], nil -} - // SDK - User API: Manage users in epilot organization(s) type SDK struct { + SDKVersion string // User API V2 UserV2 *UserV2 // User Groups @@ -76,7 +57,8 @@ type SDK struct { // Legacy User API UserV1 *UserV1 - sdkConfiguration sdkConfiguration + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } type SDKOption func(*SDK) @@ -149,14 +131,12 @@ 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{ - sdkConfiguration: sdkConfiguration{ - Language: "go", - OpenAPIDocVersion: "2.0.0", - SDKVersion: "0.10.5", - GenVersion: "2.497.0", - UserAgent: "speakeasy-sdk/terraform 0.10.5 2.497.0 2.0.0 github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk", - Hooks: hooks.New(), + SDKVersion: "0.11.0", + sdkConfiguration: config.SDKConfiguration{ + UserAgent: "speakeasy-sdk/terraform 0.11.0 2.745.2 2.0.0 github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk", + ServerList: ServerList, }, + hooks: hooks.New(), } for _, opt := range opts { opt(sdk) @@ -169,16 +149,14 @@ func New(opts ...SDKOption) *SDK { currentServerURL, _ := sdk.sdkConfiguration.GetServerDetails() serverURL := currentServerURL - serverURL, sdk.sdkConfiguration.Client = sdk.sdkConfiguration.Hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) - if serverURL != currentServerURL { + serverURL, sdk.sdkConfiguration.Client = sdk.hooks.SDKInit(currentServerURL, sdk.sdkConfiguration.Client) + if currentServerURL != serverURL { sdk.sdkConfiguration.ServerURL = serverURL } - sdk.UserV2 = newUserV2(sdk.sdkConfiguration) - - sdk.Group = newGroup(sdk.sdkConfiguration) - - sdk.UserV1 = newUserV1(sdk.sdkConfiguration) + sdk.UserV2 = newUserV2(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.Group = newGroup(sdk, sdk.sdkConfiguration, sdk.hooks) + sdk.UserV1 = newUserV1(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 -} diff --git a/internal/sdk/userv1.go b/internal/sdk/userv1.go index 4ad2801..231750d 100644 --- a/internal/sdk/userv1.go +++ b/internal/sdk/userv1.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/config" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/errors" @@ -18,25 +19,22 @@ import ( // UserV1 - Legacy User API type UserV1 struct { - sdkConfiguration sdkConfiguration + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } -func newUserV1(sdkConfig sdkConfiguration) *UserV1 { +func newUserV1(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *UserV1 { return &UserV1{ + rootSDK: rootSDK, sdkConfiguration: sdkConfig, + hooks: hooks, } } // GetMe - getMe // Get currently logged in user func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operations.GetMeResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getMe", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -60,6 +58,16 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getMe", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -112,15 +120,17 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -137,7 +147,7 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -145,13 +155,13 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -164,17 +174,17 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -224,13 +234,6 @@ func (s *UserV1) GetMe(ctx context.Context, opts ...operations.Option) (*operati // ListUsers - listUsers // Lists users in organizations you have access to func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequest, opts ...operations.Option) (*operations.ListUsersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listUsers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -254,6 +257,16 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listUsers", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -310,15 +323,17 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -335,7 +350,7 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -343,13 +358,13 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -362,17 +377,17 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -422,13 +437,6 @@ func (s *UserV1) ListUsers(ctx context.Context, request operations.ListUsersRequ // GetUser - getUser // Get user by id func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, opts ...operations.Option) (*operations.GetUserResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -452,6 +460,16 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -504,15 +522,17 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -529,7 +549,7 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -537,13 +557,13 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -556,17 +576,17 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -616,13 +636,6 @@ func (s *UserV1) GetUser(ctx context.Context, request operations.GetUserRequest, // GetUserLoginParameters - getUserLoginParameters // Get user organization login parameters by username func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations.GetUserLoginParametersRequest, opts ...operations.Option) (*operations.GetUserLoginParametersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getUserLoginParameters", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -646,6 +659,16 @@ func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations. return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getUserLoginParameters", + OAuth2Scopes: nil, + SecuritySource: nil, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -694,15 +717,17 @@ func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations. "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -719,7 +744,7 @@ func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations. err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -727,13 +752,13 @@ func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations. if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -746,17 +771,17 @@ func (s *UserV1) GetUserLoginParameters(ctx context.Context, request operations. err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } diff --git a/internal/sdk/userv2.go b/internal/sdk/userv2.go index 47bb0ad..495d732 100644 --- a/internal/sdk/userv2.go +++ b/internal/sdk/userv2.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "fmt" + "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/config" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/hooks" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/internal/utils" "github.com/epilot-dev/terraform-provider-epilot-usergroup/internal/sdk/models/errors" @@ -18,24 +19,21 @@ import ( // UserV2 - User API V2 type UserV2 struct { - sdkConfiguration sdkConfiguration + rootSDK *SDK + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks } -func newUserV2(sdkConfig sdkConfiguration) *UserV2 { +func newUserV2(rootSDK *SDK, sdkConfig config.SDKConfiguration, hooks *hooks.Hooks) *UserV2 { return &UserV2{ + rootSDK: rootSDK, sdkConfiguration: sdkConfig, + hooks: hooks, } } // SignUpUser - signUpUser func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRequest, opts ...operations.Option) (*operations.SignUpUserResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "signUpUser", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -59,6 +57,15 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "signUpUser", + OAuth2Scopes: nil, + SecuritySource: nil, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "SignupUserPayload", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -119,15 +126,17 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -144,7 +153,7 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -152,13 +161,13 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -171,17 +180,17 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -231,13 +240,6 @@ func (s *UserV2) SignUpUser(ctx context.Context, request operations.SignUpUserRe // GetMeV2 - getMeV2 // Get currently logged in user func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*operations.GetMeV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getMeV2", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -261,6 +263,16 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getMeV2", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -313,15 +325,17 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -338,7 +352,7 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -346,13 +360,13 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -365,17 +379,17 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -425,13 +439,6 @@ func (s *UserV2) GetMeV2(ctx context.Context, opts ...operations.Option) (*opera // ListUsersV2 - listUsersV2 // Get the list of organization users func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2Request, opts ...operations.Option) (*operations.ListUsersV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "listUsersV2", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -455,6 +462,16 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listUsersV2", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -511,15 +528,17 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -536,7 +555,7 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -544,13 +563,13 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -563,17 +582,17 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -623,13 +642,6 @@ func (s *UserV2) ListUsersV2(ctx context.Context, request operations.ListUsersV2 // GetUserV2 - getUserV2 // Get user details by user id func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Request, opts ...operations.Option) (*operations.GetUserV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getUserV2", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -653,6 +665,16 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getUserV2", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -705,15 +727,17 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -730,7 +754,7 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -738,13 +762,13 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -757,17 +781,17 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -817,13 +841,6 @@ func (s *UserV2) GetUserV2(ctx context.Context, request operations.GetUserV2Requ // UpdateUserV2 - updateUserV2 // Update user details func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUserV2Request, opts ...operations.Option) (*operations.UpdateUserV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "updateUserV2", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -847,6 +864,15 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateUserV2", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "UserV2", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -907,15 +933,17 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -932,7 +960,7 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -940,13 +968,13 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -959,17 +987,17 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1019,13 +1047,6 @@ func (s *UserV2) UpdateUserV2(ctx context.Context, request operations.UpdateUser // DeleteUserV2 - deleteUserV2 // Delete user by user id func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUserV2Request, opts ...operations.Option) (*operations.DeleteUserV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "deleteUserV2", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1049,6 +1070,16 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteUserV2", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1101,15 +1132,17 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1126,7 +1159,7 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1134,13 +1167,13 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1153,17 +1186,17 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1213,13 +1246,6 @@ func (s *UserV2) DeleteUserV2(ctx context.Context, request operations.DeleteUser // InviteUser - inviteUser // Creates a new user in the caller's organization and sends an invite email to activate the user func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationPayload, opts ...operations.Option) (*operations.InviteUserResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "inviteUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1243,6 +1269,15 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "inviteUser", + 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 @@ -1303,15 +1338,17 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1328,7 +1365,7 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1336,13 +1373,13 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1355,17 +1392,17 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1416,13 +1453,6 @@ func (s *UserV2) InviteUser(ctx context.Context, request *shared.UserInvitationP // ResendUserInvitation - resendUserInvitation // Resend user invitation email func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.ResendUserInvitationRequestBody, opts ...operations.Option) (*operations.ResendUserInvitationResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "resendUserInvitation", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1446,6 +1476,15 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "resendUserInvitation", + 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 @@ -1506,15 +1545,17 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1531,7 +1572,7 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1539,13 +1580,13 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1558,17 +1599,17 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1619,13 +1660,6 @@ func (s *UserV2) ResendUserInvitation(ctx context.Context, request *operations.R // GetGroupsForUser - getGroupsForUser // Get groups of a user func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGroupsForUserRequest, opts ...operations.Option) (*operations.GetGroupsForUserResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getGroupsForUser", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1649,6 +1683,16 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getGroupsForUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1701,15 +1745,17 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1726,7 +1772,7 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1734,13 +1780,13 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1753,17 +1799,17 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1813,13 +1859,6 @@ func (s *UserV2) GetGroupsForUser(ctx context.Context, request operations.GetGro // VerifyEmailWithToken - verifyEmailWithToken // Update new email using an verification token func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.VerifyEmailWithTokenRequest, opts ...operations.Option) (*operations.VerifyEmailWithTokenResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "verifyEmailWithToken", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -1843,6 +1882,15 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "verifyEmailWithToken", + OAuth2Scopes: nil, + SecuritySource: nil, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "UserVerificationPayload", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1903,15 +1951,17 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -1928,7 +1978,7 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -1936,13 +1986,13 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -1955,17 +2005,17 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -1996,13 +2046,6 @@ func (s *UserV2) VerifyEmailWithToken(ctx context.Context, request operations.Ve // CheckInviteToken - checkInviteToken // Check an invite token func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckInviteTokenRequest, opts ...operations.Option) (*operations.CheckInviteTokenResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "checkInviteToken", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2026,6 +2069,16 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "checkInviteToken", + OAuth2Scopes: nil, + SecuritySource: nil, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2078,15 +2131,17 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -2103,7 +2158,7 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -2111,13 +2166,13 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -2130,17 +2185,17 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -2191,13 +2246,6 @@ func (s *UserV2) CheckInviteToken(ctx context.Context, request operations.CheckI // ActivateUser - activateUser // Activate user using an invite token func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUserRequest, opts ...operations.Option) (*operations.ActivateUserResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "activateUser", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2221,6 +2269,15 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "activateUser", + OAuth2Scopes: nil, + SecuritySource: nil, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "UserActivationPayload", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -2281,15 +2338,17 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -2306,7 +2365,7 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -2314,13 +2373,13 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -2333,17 +2392,17 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -2376,13 +2435,6 @@ func (s *UserV2) ActivateUser(ctx context.Context, request operations.ActivateUs // RejectInvite - rejectInvite // Reject an invite func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInviteRequest, opts ...operations.Option) (*operations.RejectInviteResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "rejectInvite", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2406,6 +2458,16 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "rejectInvite", + OAuth2Scopes: nil, + SecuritySource: nil, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2458,15 +2520,17 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -2483,7 +2547,7 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -2491,13 +2555,13 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -2510,17 +2574,17 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -2573,13 +2637,6 @@ func (s *UserV2) RejectInvite(ctx context.Context, request operations.RejectInvi // // The first item in the list corresponds to the user's primary organization and must be used for initial login. func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operations.GetUserLoginParametersV2Request, opts ...operations.Option) (*operations.GetUserLoginParametersV2Response, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "getUserLoginParametersV2", - OAuth2Scopes: []string{}, - SecuritySource: nil, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2603,6 +2660,16 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getUserLoginParametersV2", + OAuth2Scopes: nil, + SecuritySource: nil, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -2651,15 +2718,17 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -2676,7 +2745,7 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -2684,13 +2753,13 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -2703,17 +2772,17 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } @@ -2763,13 +2832,6 @@ func (s *UserV2) GetUserLoginParametersV2(ctx context.Context, request operation // SwitchOrganization - switchOrganization // Switch to another organization the user is part of func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.SwitchOrganizationRequestBody, opts ...operations.Option) (*operations.SwitchOrganizationResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "switchOrganization", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -2793,6 +2855,15 @@ func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.Swi return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + SDK: s.rootSDK, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "switchOrganization", + 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 @@ -2853,15 +2924,17 @@ func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.Swi "5XX", }, }, func() (*http.Response, error) { - if req.Body != nil { + 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.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { return nil, err @@ -2878,7 +2951,7 @@ func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.Swi err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) } return httpRes, err }) @@ -2886,13 +2959,13 @@ func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.Swi if err != nil { return nil, err } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } } } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) if err != nil { return nil, err } @@ -2905,17 +2978,17 @@ func (s *UserV2) SwitchOrganization(ctx context.Context, request *operations.Swi err = fmt.Errorf("error sending request: no response") } - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err } else if utils.MatchStatusCodes([]string{}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + _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.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) if err != nil { return nil, err } diff --git a/internal/validators/float32validators/not_null.go b/internal/validators/float32validators/not_null.go new file mode 100644 index 0000000..c9a8973 --- /dev/null +++ b/internal/validators/float32validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package float32validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Float32 = Float32NotNullValidator{} + +// Float32NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Float32NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Float32NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Float32NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Float32NotNullValidator) ValidateFloat32(ctx context.Context, req validator.Float32Request, resp *validator.Float32Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Float32 { + return Float32NotNullValidator{} +} diff --git a/internal/validators/int32validators/not_null.go b/internal/validators/int32validators/not_null.go new file mode 100644 index 0000000..ec9a3f1 --- /dev/null +++ b/internal/validators/int32validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package int32validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Int32 = Int32NotNullValidator{} + +// Int32NotNullValidator validates that an attribute is not null. Most +// attributes should set Required: true instead, however in certain scenarios, +// such as a computed nested attribute, all underlying attributes must also be +// computed for planning to not show unexpected differences. +type Int32NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Int32NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Int32NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Int32NotNullValidator) ValidateInt32(ctx context.Context, req validator.Int32Request, resp *validator.Int32Response) { + if !req.ConfigValue.IsNull() { + return + } + + resp.Diagnostics.AddAttributeError( + req.Path, + "Missing Attribute Value", + req.Path.String()+": "+v.Description(ctx), + ) +} + +// NotNull returns an validator which ensures that the attribute is +// configured. Most attributes should set Required: true instead, however in +// certain scenarios, such as a computed nested attribute, all underlying +// attributes must also be computed for planning to not show unexpected +// differences. +func NotNull() validator.Int32 { + return Int32NotNullValidator{} +}