diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock new file mode 100755 index 0000000..64e110c --- /dev/null +++ b/.speakeasy/gen.lock @@ -0,0 +1,677 @@ +lockVersion: 2.0.0 +id: a592d325-751d-447c-af2a-581b9e706313 +management: + docChecksum: 58e3f2e3f4c99cfda741aa5bddc01254 + docVersion: 1.0.0 + speakeasyVersion: internal + generationVersion: 2.272.7 + releaseVersion: 1.2.0 + configChecksum: a8d00ffdd5e4bc5591aa811bbe0036ad +features: + terraform: + constsAndDefaults: 0.1.3 + core: 3.10.2 + deprecations: 2.81.1 + globalSecurity: 2.81.5 + globalServerURLs: 2.82.1 +generatedFiles: + - internal/sdk/workspace.go + - internal/sdk/notifications.go + - internal/sdk/sourcedefinition.go + - internal/sdk/actordefinitionversion.go + - internal/sdk/sourcedefinitionspecification.go + - internal/sdk/declarativesourcedefinitions.go + - internal/sdk/connectorbuilderproject.go + - internal/sdk/connectordocumentation.go + - internal/sdk/source.go + - internal/sdk/internal.go + - internal/sdk/destinationdefinition.go + - internal/sdk/destinationdefinitionspecification.go + - internal/sdk/destination.go + - internal/sdk/connection.go + - internal/sdk/state.go + - internal/sdk/operation.go + - internal/sdk/scheduler.go + - internal/sdk/sourceoauth.go + - internal/sdk/destinationoauth.go + - internal/sdk/webbackend.go + - internal/sdk/jobs.go + - internal/sdk/attempt.go + - internal/sdk/user.go + - internal/sdk/permission.go + - internal/sdk/secretspersistenceconfig.go + - internal/sdk/health.go + - internal/sdk/logs.go + - internal/sdk/openapi.go + - internal/sdk/streamstatuses.go + - internal/sdk/streams.go + - internal/sdk/instanceconfiguration.go + - internal/sdk/jobretrystates.go + - internal/sdk/organization.go + - internal/sdk/sdk.go + - examples/README.md + - go.mod + - go.sum + - internal/planmodifiers/boolplanmodifier/suppress_diff.go + - internal/planmodifiers/float64planmodifier/suppress_diff.go + - internal/planmodifiers/int64planmodifier/suppress_diff.go + - internal/planmodifiers/listplanmodifier/suppress_diff.go + - internal/planmodifiers/mapplanmodifier/suppress_diff.go + - internal/planmodifiers/numberplanmodifier/suppress_diff.go + - internal/planmodifiers/objectplanmodifier/suppress_diff.go + - internal/planmodifiers/setplanmodifier/suppress_diff.go + - internal/planmodifiers/stringplanmodifier/suppress_diff.go + - internal/planmodifiers/utils/state_check.go + - internal/provider/reflect/diags.go + - internal/provider/reflect/doc.go + - internal/provider/reflect/generic_attr_value.go + - internal/provider/reflect/helpers.go + - internal/provider/reflect/interfaces.go + - internal/provider/reflect/into.go + - internal/provider/reflect/map.go + - internal/provider/reflect/number.go + - internal/provider/reflect/options.go + - internal/provider/reflect/outof.go + - internal/provider/reflect/pointer.go + - internal/provider/reflect/primitive.go + - internal/provider/reflect/slice.go + - internal/provider/reflect/struct.go + - internal/provider/utils.go + - internal/sdk/pkg/models/sdkerrors/sdkerror.go + - internal/sdk/pkg/types/bigint.go + - internal/sdk/pkg/types/date.go + - internal/sdk/pkg/types/datetime.go + - internal/sdk/pkg/types/decimal.go + - internal/sdk/pkg/types/pointers.go + - internal/sdk/pkg/utils/contenttype.go + - internal/sdk/pkg/utils/form.go + - internal/sdk/pkg/utils/headers.go + - internal/sdk/pkg/utils/json.go + - internal/sdk/pkg/utils/pathparams.go + - internal/sdk/pkg/utils/queryparams.go + - internal/sdk/pkg/utils/requestbody.go + - internal/sdk/pkg/utils/retries.go + - internal/sdk/pkg/utils/security.go + - internal/sdk/pkg/utils/utils.go + - internal/validators/DateValidator.go + - internal/validators/ExactlyOneChild.go + - internal/validators/JSONParseValidator.go + - internal/validators/RFC3339Validator.go + - internal/validators/boolvalidators/not_null.go + - internal/validators/float64validators/not_null.go + - internal/validators/int64validators/not_null.go + - internal/validators/listvalidators/not_null.go + - internal/validators/mapvalidators/not_null.go + - internal/validators/numbervalidators/not_null.go + - internal/validators/objectvalidators/not_null.go + - internal/validators/setvalidators/not_null.go + - internal/validators/stringvalidators/not_null.go + - main.go + - terraform-registry-manifest.json + - tools/tools.go + - internal/sdk/pkg/models/operations/createworkspace.go + - internal/sdk/pkg/models/operations/deleteworkspace.go + - internal/sdk/pkg/models/operations/listworkspaces.go + - internal/sdk/pkg/models/operations/listallworkspacespaginated.go + - internal/sdk/pkg/models/operations/listworkspacespaginated.go + - internal/sdk/pkg/models/operations/listworkspacesinorganization.go + - internal/sdk/pkg/models/operations/listworkspacesbyuser.go + - internal/sdk/pkg/models/operations/getworkspace.go + - internal/sdk/pkg/models/operations/getworkspacebyslug.go + - internal/sdk/pkg/models/operations/getworkspacebyconnectionid.go + - internal/sdk/pkg/models/operations/getorganizationinfo.go + - internal/sdk/pkg/models/operations/updateworkspace.go + - internal/sdk/pkg/models/operations/updateworkspacename.go + - internal/sdk/pkg/models/operations/updateworkspacefeedback.go + - internal/sdk/pkg/models/operations/trynotificationconfig.go + - internal/sdk/pkg/models/operations/trynotificationwebhookconfig.go + - internal/sdk/pkg/models/operations/updatesourcedefinition.go + - internal/sdk/pkg/models/operations/listsourcedefinitions.go + - internal/sdk/pkg/models/operations/listlatestsourcedefinitions.go + - internal/sdk/pkg/models/operations/getsourcedefinition.go + - internal/sdk/pkg/models/operations/deletesourcedefinition.go + - internal/sdk/pkg/models/operations/listprivatesourcedefinitions.go + - internal/sdk/pkg/models/operations/listsourcedefinitionsforworkspace.go + - internal/sdk/pkg/models/operations/createcustomsourcedefinition.go + - internal/sdk/pkg/models/operations/getsourcedefinitionforworkspace.go + - internal/sdk/pkg/models/operations/getsourcedefinitionforscope.go + - internal/sdk/pkg/models/operations/grantsourcedefinition.go + - internal/sdk/pkg/models/operations/revokesourcedefinition.go + - internal/sdk/pkg/models/operations/getactordefinitionversionforsourceid.go + - internal/sdk/pkg/models/operations/getactordefinitionversionfordestinationid.go + - internal/sdk/pkg/models/operations/getsourcedefinitionspecification.go + - internal/sdk/pkg/models/operations/getspecificationforsourceid.go + - internal/sdk/pkg/models/operations/createdeclarativesourcedefinitionmanifest.go + - internal/sdk/pkg/models/operations/updatedeclarativemanifestversion.go + - internal/sdk/pkg/models/operations/listdeclarativemanifests.go + - internal/sdk/pkg/models/operations/createconnectorbuilderproject.go + - internal/sdk/pkg/models/operations/publishconnectorbuilderproject.go + - internal/sdk/pkg/models/operations/updateconnectorbuilderproject.go + - internal/sdk/pkg/models/operations/deleteconnectorbuilderproject.go + - internal/sdk/pkg/models/operations/listconnectorbuilderprojects.go + - internal/sdk/pkg/models/operations/getconnectorbuilderproject.go + - internal/sdk/pkg/models/operations/getconnectordocumentation.go + - internal/sdk/pkg/models/operations/createsource.go + - internal/sdk/pkg/models/operations/updatesource.go + - internal/sdk/pkg/models/operations/partialupdatesource.go + - internal/sdk/pkg/models/operations/upgradesourceversion.go + - internal/sdk/pkg/models/operations/listsourcesforworkspace.go + - internal/sdk/pkg/models/operations/listsourcesforworkspacepaginated.go + - internal/sdk/pkg/models/operations/getsource.go + - internal/sdk/pkg/models/operations/getmostrecentsourceactorcatalog.go + - internal/sdk/pkg/models/operations/searchsources.go + - internal/sdk/pkg/models/operations/clonesource.go + - internal/sdk/pkg/models/operations/deletesource.go + - internal/sdk/pkg/models/operations/checkconnectiontosource.go + - internal/sdk/pkg/models/operations/checkconnectiontosourceforupdate.go + - internal/sdk/pkg/models/operations/discoverschemaforsource.go + - internal/sdk/pkg/models/operations/applyschemachangeforsource.go + - internal/sdk/pkg/models/operations/writediscovercatalogresult.go + - internal/sdk/pkg/models/operations/createorupdatestate.go + - internal/sdk/pkg/models/operations/autodisableconnection.go + - internal/sdk/pkg/models/operations/gettaskqueuename.go + - internal/sdk/pkg/models/operations/createjob.go + - internal/sdk/pkg/models/operations/jobsuccesswithattemptnumber.go + - internal/sdk/pkg/models/operations/getattemptnormalizationstatusesforjob.go + - internal/sdk/pkg/models/operations/getjobinput.go + - internal/sdk/pkg/models/operations/getcheckinput.go + - internal/sdk/pkg/models/operations/failnonterminaljobs.go + - internal/sdk/pkg/models/operations/reportjobstart.go + - internal/sdk/pkg/models/operations/jobfailure.go + - internal/sdk/pkg/models/operations/deletestreamresetrecordsforjob.go + - internal/sdk/pkg/models/operations/createnewattemptnumber.go + - internal/sdk/pkg/models/operations/setworkflowinattempt.go + - internal/sdk/pkg/models/operations/savestats.go + - internal/sdk/pkg/models/operations/savesyncconfig.go + - internal/sdk/pkg/models/operations/failattempt.go + - internal/sdk/pkg/models/operations/getattemptcombinedstats.go + - internal/sdk/pkg/models/operations/getattemptforjob.go + - internal/sdk/pkg/models/operations/didpreviousjobsucceed.go + - internal/sdk/pkg/models/operations/persistjobcancellation.go + - internal/sdk/pkg/models/operations/updatedestinationdefinition.go + - internal/sdk/pkg/models/operations/listdestinationdefinitions.go + - internal/sdk/pkg/models/operations/listlatestdestinationdefinitions.go + - internal/sdk/pkg/models/operations/getdestinationdefinition.go + - internal/sdk/pkg/models/operations/deletedestinationdefinition.go + - internal/sdk/pkg/models/operations/listprivatedestinationdefinitions.go + - internal/sdk/pkg/models/operations/listdestinationdefinitionsforworkspace.go + - internal/sdk/pkg/models/operations/createcustomdestinationdefinition.go + - internal/sdk/pkg/models/operations/getdestinationdefinitionforworkspace.go + - internal/sdk/pkg/models/operations/getdestinationdefinitionforscope.go + - internal/sdk/pkg/models/operations/grantdestinationdefinition.go + - internal/sdk/pkg/models/operations/revokedestinationdefinition.go + - internal/sdk/pkg/models/operations/getdestinationdefinitionspecification.go + - internal/sdk/pkg/models/operations/getspecificationfordestinationid.go + - internal/sdk/pkg/models/operations/createdestination.go + - internal/sdk/pkg/models/operations/updatedestination.go + - internal/sdk/pkg/models/operations/partialupdatedestination.go + - internal/sdk/pkg/models/operations/upgradedestinationversion.go + - internal/sdk/pkg/models/operations/listdestinationsforworkspace.go + - internal/sdk/pkg/models/operations/listdestinationsforworkspacespaginated.go + - internal/sdk/pkg/models/operations/getdestination.go + - internal/sdk/pkg/models/operations/searchdestinations.go + - internal/sdk/pkg/models/operations/checkconnectiontodestination.go + - internal/sdk/pkg/models/operations/checkconnectiontodestinationforupdate.go + - internal/sdk/pkg/models/operations/deletedestination.go + - internal/sdk/pkg/models/operations/clonedestination.go + - internal/sdk/pkg/models/operations/createconnection.go + - internal/sdk/pkg/models/operations/updateconnection.go + - internal/sdk/pkg/models/operations/listconnectionsforworkspace.go + - internal/sdk/pkg/models/operations/listconnectionsforworkspacespaginated.go + - internal/sdk/pkg/models/operations/listallconnectionsforworkspace.go + - internal/sdk/pkg/models/operations/getconnectionstatuses.go + - internal/sdk/pkg/models/operations/getconnectionsyncprogress.go + - internal/sdk/pkg/models/operations/getconnectionuptimehistory.go + - internal/sdk/pkg/models/operations/getconnectiondatahistory.go + - internal/sdk/pkg/models/operations/getconnectionstreamhistory.go + - internal/sdk/pkg/models/operations/getconnection.go + - internal/sdk/pkg/models/operations/listconnectionsbyactordefinition.go + - internal/sdk/pkg/models/operations/applyschemachangeforconnection.go + - internal/sdk/pkg/models/operations/searchconnections.go + - internal/sdk/pkg/models/operations/deleteconnection.go + - internal/sdk/pkg/models/operations/syncconnection.go + - internal/sdk/pkg/models/operations/resetconnection.go + - internal/sdk/pkg/models/operations/resetconnectionstream.go + - internal/sdk/pkg/models/operations/getstate.go + - internal/sdk/pkg/models/operations/createorupdatestatesafe.go + - internal/sdk/pkg/models/operations/checkoperation.go + - internal/sdk/pkg/models/operations/createoperation.go + - internal/sdk/pkg/models/operations/updateoperation.go + - internal/sdk/pkg/models/operations/listoperationsforconnection.go + - internal/sdk/pkg/models/operations/getoperation.go + - internal/sdk/pkg/models/operations/deleteoperation.go + - internal/sdk/pkg/models/operations/executesourcecheckconnection.go + - internal/sdk/pkg/models/operations/executesourcediscoverschema.go + - internal/sdk/pkg/models/operations/executedestinationcheckconnection.go + - internal/sdk/pkg/models/operations/setinstancewidesourceoauthparams.go + - internal/sdk/pkg/models/operations/getsourceoauthconsent.go + - internal/sdk/pkg/models/operations/completesourceoauth.go + - internal/sdk/pkg/models/operations/revokesourceoauthtokens.go + - internal/sdk/pkg/models/operations/getdestinationoauthconsent.go + - internal/sdk/pkg/models/operations/completedestinationoauth.go + - internal/sdk/pkg/models/operations/setinstancewidedestinationoauthparams.go + - internal/sdk/pkg/models/operations/webbackendcheckupdates.go + - internal/sdk/pkg/models/operations/webbackendlistconnectionsforworkspace.go + - internal/sdk/pkg/models/operations/webbackendgetconnection.go + - internal/sdk/pkg/models/operations/webbackendcreateconnection.go + - internal/sdk/pkg/models/operations/webbackendupdateconnection.go + - internal/sdk/pkg/models/operations/getstatetype.go + - internal/sdk/pkg/models/operations/webbackendgetworkspacestate.go + - internal/sdk/pkg/models/operations/webbackendlistgeographies.go + - internal/sdk/pkg/models/operations/listjobsfor.go + - internal/sdk/pkg/models/operations/listjobsforworkspaces.go + - internal/sdk/pkg/models/operations/getjobinfo.go + - internal/sdk/pkg/models/operations/getlastreplicationjob.go + - internal/sdk/pkg/models/operations/getjobinfowithoutlogs.go + - internal/sdk/pkg/models/operations/getjobinfolight.go + - internal/sdk/pkg/models/operations/canceljob.go + - internal/sdk/pkg/models/operations/getjobdebuginfo.go + - internal/sdk/pkg/models/operations/createuser.go + - internal/sdk/pkg/models/operations/getuser.go + - internal/sdk/pkg/models/operations/getuserbyauthid.go + - internal/sdk/pkg/models/operations/getorcreateuserbyauthid.go + - internal/sdk/pkg/models/operations/updateuser.go + - internal/sdk/pkg/models/operations/deleteuser.go + - internal/sdk/pkg/models/operations/listusersinworkspace.go + - internal/sdk/pkg/models/operations/listusersinorganization.go + - internal/sdk/pkg/models/operations/listinstanceadminusers.go + - internal/sdk/pkg/models/operations/createpermission.go + - internal/sdk/pkg/models/operations/getpermission.go + - internal/sdk/pkg/models/operations/checkpermissions.go + - internal/sdk/pkg/models/operations/checkpermissionsacrossmultipleworkspaces.go + - internal/sdk/pkg/models/operations/updatepermission.go + - internal/sdk/pkg/models/operations/deletepermission.go + - internal/sdk/pkg/models/operations/deleteuserfromworkspace.go + - internal/sdk/pkg/models/operations/listpermissionsbyuser.go + - internal/sdk/pkg/models/operations/getsecretspersistenceconfig.go + - internal/sdk/pkg/models/operations/createorupdatesecretspersistenceconfig.go + - internal/sdk/pkg/models/operations/gethealthcheck.go + - internal/sdk/pkg/models/operations/getlogs.go + - internal/sdk/pkg/models/operations/getopenapispec.go + - internal/sdk/pkg/models/operations/getstreamstatuses.go + - internal/sdk/pkg/models/operations/getstreamstatusesbyrunstate.go + - internal/sdk/pkg/models/operations/createstreamstatus.go + - internal/sdk/pkg/models/operations/updatestreamstatus.go + - internal/sdk/pkg/models/operations/getinstanceconfiguration.go + - internal/sdk/pkg/models/operations/setupinstanceconfiguration.go + - internal/sdk/pkg/models/operations/createorupdate.go + - internal/sdk/pkg/models/operations/get.go + - internal/sdk/pkg/models/operations/getorganization.go + - internal/sdk/pkg/models/operations/createorganization.go + - internal/sdk/pkg/models/operations/updateorganization.go + - internal/sdk/pkg/models/operations/deleteorganization.go + - internal/sdk/pkg/models/operations/listorganizationsbyuser.go + - internal/sdk/pkg/models/shared/invalidinputexceptioninfo.go + - internal/sdk/pkg/models/shared/invalidinputproperty.go + - internal/sdk/pkg/models/shared/workspaceread.go + - internal/sdk/pkg/models/shared/webhookconfigread.go + - internal/sdk/pkg/models/shared/geography.go + - internal/sdk/pkg/models/shared/notificationsettings.go + - internal/sdk/pkg/models/shared/notificationitem.go + - internal/sdk/pkg/models/shared/customerionotificationconfiguration.go + - internal/sdk/pkg/models/shared/slacknotificationconfiguration.go + - internal/sdk/pkg/models/shared/notificationtype.go + - internal/sdk/pkg/models/shared/notification.go + - internal/sdk/pkg/models/shared/workspacecreate.go + - internal/sdk/pkg/models/shared/webhookconfigwrite.go + - internal/sdk/pkg/models/shared/notfoundknownexceptioninfo.go + - internal/sdk/pkg/models/shared/workspaceidrequestbody.go + - internal/sdk/pkg/models/shared/workspacereadlist.go + - internal/sdk/pkg/models/shared/listresourcesforworkspacesrequestbody.go + - internal/sdk/pkg/models/shared/pagination.go + - internal/sdk/pkg/models/shared/listworkspacesinorganizationrequestbody.go + - internal/sdk/pkg/models/shared/listworkspacesbyuserrequestbody.go + - internal/sdk/pkg/models/shared/slugrequestbody.go + - internal/sdk/pkg/models/shared/connectionidrequestbody.go + - internal/sdk/pkg/models/shared/workspaceorganizationinforead.go + - internal/sdk/pkg/models/shared/workspaceupdate.go + - internal/sdk/pkg/models/shared/workspaceupdatename.go + - internal/sdk/pkg/models/shared/workspacegivefeedback.go + - internal/sdk/pkg/models/shared/notificationread.go + - internal/sdk/pkg/models/shared/notificationwebhookconfigvalidationrequestbody.go + - internal/sdk/pkg/models/shared/notificationtrigger.go + - internal/sdk/pkg/models/shared/sourcedefinitionread.go + - internal/sdk/pkg/models/shared/actordefinitionresourcerequirements.go + - internal/sdk/pkg/models/shared/jobtyperesourcelimit.go + - internal/sdk/pkg/models/shared/resourcerequirements.go + - internal/sdk/pkg/models/shared/jobtype.go + - internal/sdk/pkg/models/shared/releasestage.go + - internal/sdk/pkg/models/shared/supportlevel.go + - internal/sdk/pkg/models/shared/sourcedefinitionupdate.go + - internal/sdk/pkg/models/shared/sourcedefinitionreadlist.go + - internal/sdk/pkg/models/shared/sourcedefinitionidrequestbody.go + - internal/sdk/pkg/models/shared/privatesourcedefinitionreadlist.go + - internal/sdk/pkg/models/shared/privatesourcedefinitionread.go + - internal/sdk/pkg/models/shared/customsourcedefinitioncreate.go + - internal/sdk/pkg/models/shared/sourcedefinitioncreate.go + - internal/sdk/pkg/models/shared/scopetype.go + - internal/sdk/pkg/models/shared/sourcedefinitionidwithworkspaceid.go + - internal/sdk/pkg/models/shared/actordefinitionidwithscope.go + - internal/sdk/pkg/models/shared/actordefinitionversionread.go + - internal/sdk/pkg/models/shared/actordefinitionversionbreakingchanges.go + - internal/sdk/pkg/models/shared/actordefinitionbreakingchange.go + - internal/sdk/pkg/models/shared/supportstate.go + - internal/sdk/pkg/models/shared/normalizationdestinationdefinitionconfig.go + - internal/sdk/pkg/models/shared/sourceidrequestbody.go + - internal/sdk/pkg/models/shared/destinationidrequestbody.go + - internal/sdk/pkg/models/shared/sourcedefinitionspecificationread.go + - internal/sdk/pkg/models/shared/synchronousjobread.go + - internal/sdk/pkg/models/shared/failurereason.go + - internal/sdk/pkg/models/shared/failuretype.go + - internal/sdk/pkg/models/shared/failureorigin.go + - internal/sdk/pkg/models/shared/logread.go + - internal/sdk/pkg/models/shared/jobconfigtype.go + - internal/sdk/pkg/models/shared/advancedauth.go + - internal/sdk/pkg/models/shared/oauthconfigspecification.go + - internal/sdk/pkg/models/shared/sourcedefinitionspecification.go + - internal/sdk/pkg/models/shared/declarativesourcedefinitioncreatemanifestrequestbody.go + - internal/sdk/pkg/models/shared/declarativesourcemanifest.go + - internal/sdk/pkg/models/shared/declarativemanifest.go + - internal/sdk/pkg/models/shared/updateactivemanifestrequestbody.go + - internal/sdk/pkg/models/shared/declarativemanifestsreadlist.go + - internal/sdk/pkg/models/shared/declarativemanifestversionread.go + - internal/sdk/pkg/models/shared/listdeclarativemanifestsrequestbody.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectidwithworkspaceid.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectwithworkspaceid.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectdetails.go + - internal/sdk/pkg/models/shared/sourcedefinitionidbody.go + - internal/sdk/pkg/models/shared/connectorbuilderpublishrequestbody.go + - internal/sdk/pkg/models/shared/existingconnectorbuilderprojectwithworkspaceid.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectreadlist.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectdetailsread.go + - internal/sdk/pkg/models/shared/connectorbuilderprojectread.go + - internal/sdk/pkg/models/shared/declarativemanifestread.go + - internal/sdk/pkg/models/shared/connectordocumentationread.go + - internal/sdk/pkg/models/shared/connectordocumentationrequestbody.go + - internal/sdk/pkg/models/shared/actortype.go + - internal/sdk/pkg/models/shared/sourceread.go + - internal/sdk/pkg/models/shared/sourcecreate.go + - internal/sdk/pkg/models/shared/sourceupdate.go + - internal/sdk/pkg/models/shared/partialsourceupdate.go + - internal/sdk/pkg/models/shared/sourcereadlist.go + - internal/sdk/pkg/models/shared/actorcatalogwithupdatedat.go + - internal/sdk/pkg/models/shared/sourcesearch.go + - internal/sdk/pkg/models/shared/sourceclonerequestbody.go + - internal/sdk/pkg/models/shared/sourcecloneconfiguration.go + - internal/sdk/pkg/models/shared/checkconnectionread.go + - internal/sdk/pkg/models/shared/sourcediscoverschemaread.go + - internal/sdk/pkg/models/shared/connectionstatus.go + - internal/sdk/pkg/models/shared/catalogdiff.go + - internal/sdk/pkg/models/shared/streamtransform.go + - internal/sdk/pkg/models/shared/fieldtransform.go + - internal/sdk/pkg/models/shared/fieldschemaupdate.go + - internal/sdk/pkg/models/shared/fieldschema.go + - internal/sdk/pkg/models/shared/fieldremove.go + - internal/sdk/pkg/models/shared/fieldadd.go + - internal/sdk/pkg/models/shared/streamdescriptor.go + - internal/sdk/pkg/models/shared/airbytecatalog.go + - internal/sdk/pkg/models/shared/airbytestreamandconfiguration.go + - internal/sdk/pkg/models/shared/airbytestreamconfiguration.go + - internal/sdk/pkg/models/shared/selectedfieldinfo.go + - internal/sdk/pkg/models/shared/destinationsyncmode.go + - internal/sdk/pkg/models/shared/syncmode.go + - internal/sdk/pkg/models/shared/airbytestream.go + - internal/sdk/pkg/models/shared/sourcediscoverschemarequestbody.go + - internal/sdk/pkg/models/shared/sourceautopropagatechange.go + - internal/sdk/pkg/models/shared/discovercatalogresult.go + - internal/sdk/pkg/models/shared/sourcediscoverschemawriterequestbody.go + - internal/sdk/pkg/models/shared/connectionstate.go + - internal/sdk/pkg/models/shared/globalstate.go + - internal/sdk/pkg/models/shared/streamstate.go + - internal/sdk/pkg/models/shared/stateblob.go + - internal/sdk/pkg/models/shared/connectionstatetype.go + - internal/sdk/pkg/models/shared/connectionstatecreateorupdate.go + - internal/sdk/pkg/models/shared/internaloperationresult.go + - internal/sdk/pkg/models/shared/taskqueuenameread.go + - internal/sdk/pkg/models/shared/jobinforead.go + - internal/sdk/pkg/models/shared/attemptinforead.go + - internal/sdk/pkg/models/shared/attemptread.go + - internal/sdk/pkg/models/shared/attemptfailuresummary.go + - internal/sdk/pkg/models/shared/attemptstreamstats.go + - internal/sdk/pkg/models/shared/attemptstats.go + - internal/sdk/pkg/models/shared/attemptstatus.go + - internal/sdk/pkg/models/shared/jobread.go + - internal/sdk/pkg/models/shared/resetconfig.go + - internal/sdk/pkg/models/shared/jobstatus.go + - internal/sdk/pkg/models/shared/jobcreate.go + - internal/sdk/pkg/models/shared/attemptnormalizationstatusreadlist.go + - internal/sdk/pkg/models/shared/attemptnormalizationstatusread.go + - internal/sdk/pkg/models/shared/jobidrequestbody.go + - internal/sdk/pkg/models/shared/syncinput.go + - internal/sdk/pkg/models/shared/checkinput.go + - internal/sdk/pkg/models/shared/setworkflowinattemptrequestbody.go + - internal/sdk/pkg/models/shared/savestatsrequestbody.go + - internal/sdk/pkg/models/shared/saveattemptsyncconfigrequestbody.go + - internal/sdk/pkg/models/shared/attemptsyncconfig.go + - internal/sdk/pkg/models/shared/getattemptstatsrequestbody.go + - internal/sdk/pkg/models/shared/booleanread.go + - internal/sdk/pkg/models/shared/connectionjobrequestbody.go + - internal/sdk/pkg/models/shared/persistcanceljobrequestbody.go + - internal/sdk/pkg/models/shared/destinationdefinitionread.go + - internal/sdk/pkg/models/shared/destinationdefinitionupdate.go + - internal/sdk/pkg/models/shared/destinationdefinitionreadlist.go + - internal/sdk/pkg/models/shared/destinationdefinitionidrequestbody.go + - internal/sdk/pkg/models/shared/privatedestinationdefinitionreadlist.go + - internal/sdk/pkg/models/shared/privatedestinationdefinitionread.go + - internal/sdk/pkg/models/shared/customdestinationdefinitioncreate.go + - internal/sdk/pkg/models/shared/destinationdefinitioncreate.go + - internal/sdk/pkg/models/shared/destinationdefinitionidwithworkspaceid.go + - internal/sdk/pkg/models/shared/destinationdefinitionspecificationread.go + - internal/sdk/pkg/models/shared/destinationdefinitionspecification.go + - internal/sdk/pkg/models/shared/destinationread.go + - internal/sdk/pkg/models/shared/destinationcreate.go + - internal/sdk/pkg/models/shared/destinationupdate.go + - internal/sdk/pkg/models/shared/partialdestinationupdate.go + - internal/sdk/pkg/models/shared/destinationreadlist.go + - internal/sdk/pkg/models/shared/destinationsearch.go + - internal/sdk/pkg/models/shared/destinationclonerequestbody.go + - internal/sdk/pkg/models/shared/destinationcloneconfiguration.go + - internal/sdk/pkg/models/shared/connectionread.go + - internal/sdk/pkg/models/shared/nonbreakingchangespreference.go + - internal/sdk/pkg/models/shared/connectionscheduledata.go + - internal/sdk/pkg/models/shared/connectionscheduletype.go + - internal/sdk/pkg/models/shared/namespacedefinitiontype.go + - internal/sdk/pkg/models/shared/connectioncreate.go + - internal/sdk/pkg/models/shared/connectionupdate.go + - internal/sdk/pkg/models/shared/connectionreadlist.go + - internal/sdk/pkg/models/shared/listconnectionsforworkspacesrequestbody.go + - internal/sdk/pkg/models/shared/connectionstatusread.go + - internal/sdk/pkg/models/shared/connectionstatusesrequestbody.go + - internal/sdk/pkg/models/shared/connectionsyncprogressreaditem.go + - internal/sdk/pkg/models/shared/connectionsyncresultread.go + - internal/sdk/pkg/models/shared/connectionuptimehistoryrequestbody.go + - internal/sdk/pkg/models/shared/connectiondatahistoryreaditem.go + - internal/sdk/pkg/models/shared/connectiondatahistoryrequestbody.go + - internal/sdk/pkg/models/shared/connectionstreamhistoryreaditem.go + - internal/sdk/pkg/models/shared/connectionstreamhistoryrequestbody.go + - internal/sdk/pkg/models/shared/actordefinitionrequestbody.go + - internal/sdk/pkg/models/shared/connectionautopropagateresult.go + - internal/sdk/pkg/models/shared/connectionautopropagateschemachange.go + - internal/sdk/pkg/models/shared/connectionsearch.go + - internal/sdk/pkg/models/shared/connectionschedule.go + - internal/sdk/pkg/models/shared/connectionstreamrequestbody.go + - internal/sdk/pkg/models/shared/connectionstream.go + - internal/sdk/pkg/models/shared/knownexceptioninfo.go + - internal/sdk/pkg/models/shared/checkoperationread.go + - internal/sdk/pkg/models/shared/operatorconfiguration.go + - internal/sdk/pkg/models/shared/operatorwebhook.go + - internal/sdk/pkg/models/shared/operatordbt.go + - internal/sdk/pkg/models/shared/operatornormalization.go + - internal/sdk/pkg/models/shared/operatortype.go + - internal/sdk/pkg/models/shared/operationread.go + - internal/sdk/pkg/models/shared/operationcreate.go + - internal/sdk/pkg/models/shared/operationupdate.go + - internal/sdk/pkg/models/shared/operationreadlist.go + - internal/sdk/pkg/models/shared/operationidrequestbody.go + - internal/sdk/pkg/models/shared/sourcecoreconfig.go + - internal/sdk/pkg/models/shared/destinationcoreconfig.go + - internal/sdk/pkg/models/shared/setinstancewidesourceoauthparamsrequestbody.go + - internal/sdk/pkg/models/shared/oauthconsentread.go + - internal/sdk/pkg/models/shared/sourceoauthconsentrequest.go + - internal/sdk/pkg/models/shared/completeoauthresponse.go + - internal/sdk/pkg/models/shared/completesourceoauthrequest.go + - internal/sdk/pkg/models/shared/revokesourceoauthtokensrequest.go + - internal/sdk/pkg/models/shared/destinationoauthconsentrequest.go + - internal/sdk/pkg/models/shared/completedestinationoauthrequest.go + - internal/sdk/pkg/models/shared/setinstancewidedestinationoauthparamsrequestbody.go + - internal/sdk/pkg/models/shared/webbackendcheckupdatesread.go + - internal/sdk/pkg/models/shared/webbackendconnectionreadlist.go + - internal/sdk/pkg/models/shared/webbackendconnectionlistitem.go + - internal/sdk/pkg/models/shared/schemachange.go + - internal/sdk/pkg/models/shared/destinationsnippetread.go + - internal/sdk/pkg/models/shared/sourcesnippetread.go + - internal/sdk/pkg/models/shared/webbackendconnectionlistrequestbody.go + - internal/sdk/pkg/models/shared/webbackendconnectionread.go + - internal/sdk/pkg/models/shared/webbackendconnectionrequestbody.go + - internal/sdk/pkg/models/shared/webbackendconnectioncreate.go + - internal/sdk/pkg/models/shared/webbackendconnectionupdate.go + - internal/sdk/pkg/models/shared/webbackendoperationcreateorupdate.go + - internal/sdk/pkg/models/shared/webbackendworkspacestateresult.go + - internal/sdk/pkg/models/shared/webbackendworkspacestate.go + - internal/sdk/pkg/models/shared/webbackendgeographieslistresult.go + - internal/sdk/pkg/models/shared/jobreadlist.go + - internal/sdk/pkg/models/shared/jobwithattemptsread.go + - internal/sdk/pkg/models/shared/joblistrequestbody.go + - internal/sdk/pkg/models/shared/joblistforworkspacesrequestbody.go + - internal/sdk/pkg/models/shared/joboptionalread.go + - internal/sdk/pkg/models/shared/jobinfolightread.go + - internal/sdk/pkg/models/shared/jobdebuginforead.go + - internal/sdk/pkg/models/shared/workflowstateread.go + - internal/sdk/pkg/models/shared/jobdebugread.go + - internal/sdk/pkg/models/shared/userread.go + - internal/sdk/pkg/models/shared/userstatus.go + - internal/sdk/pkg/models/shared/authprovider.go + - internal/sdk/pkg/models/shared/usercreate.go + - internal/sdk/pkg/models/shared/useridrequestbody.go + - internal/sdk/pkg/models/shared/userauthidrequestbody.go + - internal/sdk/pkg/models/shared/usergetorcreatebyauthidresponse.go + - internal/sdk/pkg/models/shared/userupdate.go + - internal/sdk/pkg/models/shared/workspaceuserreadlist.go + - internal/sdk/pkg/models/shared/workspaceuserread.go + - internal/sdk/pkg/models/shared/permissiontype.go + - internal/sdk/pkg/models/shared/organizationuserreadlist.go + - internal/sdk/pkg/models/shared/organizationuserread.go + - internal/sdk/pkg/models/shared/organizationidrequestbody.go + - internal/sdk/pkg/models/shared/userwithpermissioninforeadlist.go + - internal/sdk/pkg/models/shared/userwithpermissioninforead.go + - internal/sdk/pkg/models/shared/permissionread.go + - internal/sdk/pkg/models/shared/permissioncreate.go + - internal/sdk/pkg/models/shared/permissionidrequestbody.go + - internal/sdk/pkg/models/shared/permissioncheckread.go + - internal/sdk/pkg/models/shared/permissioncheckrequest.go + - internal/sdk/pkg/models/shared/permissionscheckmultipleworkspacesrequest.go + - internal/sdk/pkg/models/shared/permissionupdate.go + - internal/sdk/pkg/models/shared/permissiondeleteuserfromworkspacerequestbody.go + - internal/sdk/pkg/models/shared/permissionreadlist.go + - internal/sdk/pkg/models/shared/secretpersistenceconfig.go + - internal/sdk/pkg/models/shared/secretpersistencetype.go + - internal/sdk/pkg/models/shared/createorupdatesecretspersistenceconfigrequestbody.go + - internal/sdk/pkg/models/shared/healthcheckread.go + - internal/sdk/pkg/models/shared/logsrequestbody.go + - internal/sdk/pkg/models/shared/logtype.go + - internal/sdk/pkg/models/shared/streamstatusreadlist.go + - internal/sdk/pkg/models/shared/streamstatusread.go + - internal/sdk/pkg/models/shared/streamstatusrunstate.go + - internal/sdk/pkg/models/shared/streamstatusjobtype.go + - internal/sdk/pkg/models/shared/streamstatusincompleteruncause.go + - internal/sdk/pkg/models/shared/streamstatuslistrequestbody.go + - internal/sdk/pkg/models/shared/streamstatuscreaterequestbody.go + - internal/sdk/pkg/models/shared/streamstatusupdaterequestbody.go + - internal/sdk/pkg/models/shared/instanceconfigurationresponse.go + - internal/sdk/pkg/models/shared/authconfiguration.go + - internal/sdk/pkg/models/shared/instanceconfigurationsetuprequestbody.go + - internal/sdk/pkg/models/shared/jobretrystaterequestbody.go + - internal/sdk/pkg/models/shared/retrystateread.go + - internal/sdk/pkg/models/shared/organizationread.go + - internal/sdk/pkg/models/shared/organizationcreaterequestbody.go + - internal/sdk/pkg/models/shared/organizationupdaterequestbody.go + - internal/sdk/pkg/models/shared/organizationreadlist.go + - internal/sdk/pkg/models/shared/listorganizationsbyuserrequestbody.go + - internal/sdk/pkg/models/shared/security.go + - internal/provider/type_resource_requirements.go + - internal/provider/type_basic_schedule.go + - internal/provider/type_cron.go + - internal/provider/type_connection_schedule_data.go + - internal/provider/type_selected_field_info.go + - internal/provider/type_airbyte_stream_configuration.go + - internal/provider/type_airbyte_stream.go + - internal/provider/type_airbyte_stream_and_configuration.go + - internal/provider/type_airbyte_catalog.go + - internal/provider/type_normalization_destination_definition_config.go + - internal/provider/type_job_type_resource_limit.go + - internal/provider/type_actor_definition_resource_requirements.go + - internal/provider/type_operator_dbt.go + - internal/provider/type_operator_normalization.go + - internal/provider/type_dbt_cloud.go + - internal/provider/type_operator_webhook.go + - internal/provider/type_operator_configuration.go + - internal/provider/type_declarative_manifest.go + - internal/provider/type_declarative_source_manifest.go + - internal/provider/type_slack_notification_configuration.go + - internal/provider/type_notification.go + - internal/provider/type_notification_item.go + - internal/provider/type_notification_settings.go + - internal/provider/type_webhook_config_read.go + - internal/provider/type_stream_descriptor.go + - internal/provider/type_field_add.go + - internal/provider/type_field_schema_update.go + - internal/provider/type_field_transform.go + - internal/provider/type_stream_transform.go + - internal/provider/type_catalog_diff.go + - internal/provider/type_failure_reason.go + - internal/provider/type_log_read.go + - internal/provider/type_synchronous_job_read.go + - internal/provider/type_webhook_config_read1.go + - USAGE.md + - internal/provider/provider.go + - examples/provider/provider.tf + - internal/provider/connection_resource.go + - internal/provider/connection_resource_sdk.go + - examples/resources/airbyte_connection/resource.tf + - internal/provider/destination_resource.go + - internal/provider/destination_resource_sdk.go + - examples/resources/airbyte_destination/resource.tf + - internal/provider/destinationdefinition_resource.go + - internal/provider/destinationdefinition_resource_sdk.go + - examples/resources/airbyte_destination_definition/resource.tf + - internal/provider/operation_resource.go + - internal/provider/operation_resource_sdk.go + - examples/resources/airbyte_operation/resource.tf + - internal/provider/source_resource.go + - internal/provider/source_resource_sdk.go + - examples/resources/airbyte_source/resource.tf + - internal/provider/sourcedefinition_resource.go + - internal/provider/sourcedefinition_resource_sdk.go + - examples/resources/airbyte_source_definition/resource.tf + - internal/provider/sourcedefinitionmanifest_resource.go + - internal/provider/sourcedefinitionmanifest_resource_sdk.go + - examples/resources/airbyte_source_definition_manifest/resource.tf + - internal/provider/workspace_resource.go + - internal/provider/workspace_resource_sdk.go + - examples/resources/airbyte_workspace/resource.tf + - internal/provider/connection_data_source.go + - internal/provider/connection_data_source_sdk.go + - examples/data-sources/airbyte_connection/data-source.tf + - internal/provider/destination_data_source.go + - internal/provider/destination_data_source_sdk.go + - examples/data-sources/airbyte_destination/data-source.tf + - internal/provider/destinationdefinition_data_source.go + - internal/provider/destinationdefinition_data_source_sdk.go + - examples/data-sources/airbyte_destination_definition/data-source.tf + - internal/provider/operation_data_source.go + - internal/provider/operation_data_source_sdk.go + - examples/data-sources/airbyte_operation/data-source.tf + - internal/provider/source_data_source.go + - internal/provider/source_data_source_sdk.go + - examples/data-sources/airbyte_source/data-source.tf + - internal/provider/sourcedefinition_data_source.go + - internal/provider/sourcedefinition_data_source_sdk.go + - examples/data-sources/airbyte_source_definition/data-source.tf + - internal/provider/sourceschema_data_source.go + - internal/provider/sourceschema_data_source_sdk.go + - examples/data-sources/airbyte_source_schema/data-source.tf + - internal/provider/workspace_data_source.go + - internal/provider/workspace_data_source_sdk.go + - examples/data-sources/airbyte_workspace/data-source.tf + - internal/sdk/pkg/models/operations/options.go + - .gitattributes diff --git a/README.md b/README.md index 4c80dc2..adcfe69 100755 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ terraform { required_providers { airbyte = { source = "aballiet/airbyte-oss" - version = "1.1.1" + version = "1.2.0" } } } diff --git a/docs/index.md b/docs/index.md index 611e38e..a314e1d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,7 +40,7 @@ terraform { required_providers { airbyte = { source = "aballiet/airbyte-oss" - version = "1.1.0" + version = "1.2.0" } } } diff --git a/examples/data-sources/airbyte_connection/data-source.tf b/examples/data-sources/airbyte_connection/data-source.tf index 00c6fc6..3a9b26e 100644 --- a/examples/data-sources/airbyte_connection/data-source.tf +++ b/examples/data-sources/airbyte_connection/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_connection" "my_connection" { - connection_id = "aaa86acf-aeba-4dc8-b85b-cf425a69f844" + connection_id = "0839cded-c24b-4e26-ba48-a24e9eaedfd4" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_destination/data-source.tf b/examples/data-sources/airbyte_destination/data-source.tf index fbe9070..7a7bb51 100644 --- a/examples/data-sources/airbyte_destination/data-source.tf +++ b/examples/data-sources/airbyte_destination/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_destination" "my_destination" { - destination_id = "cbc07f65-e5d1-4847-8196-e36f66cd38de" + destination_id = "01e41ae1-e814-42cf-8767-202da61c2ec3" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_destination_definition/data-source.tf b/examples/data-sources/airbyte_destination_definition/data-source.tf index 4be4e87..2d4e1fe 100644 --- a/examples/data-sources/airbyte_destination_definition/data-source.tf +++ b/examples/data-sources/airbyte_destination_definition/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_destination_definition" "my_destinationdefinition" { - destination_definition_id = "26a55755-8711-41c3-96fa-6ed0923bff39" + destination_definition_id = "9100781f-2dad-4fe3-95f9-7cbac4a9fe32" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_operation/data-source.tf b/examples/data-sources/airbyte_operation/data-source.tf index 73a0714..b6b33d5 100644 --- a/examples/data-sources/airbyte_operation/data-source.tf +++ b/examples/data-sources/airbyte_operation/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_operation" "my_operation" { - operation_id = "20533529-4d0a-4ddf-b687-ccb9e13e7ba5" + operation_id = "ed2caaa8-6acf-4aeb-adc8-f85bcf425a69" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_source/data-source.tf b/examples/data-sources/airbyte_source/data-source.tf index b56e155..0612024 100644 --- a/examples/data-sources/airbyte_source/data-source.tf +++ b/examples/data-sources/airbyte_source/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_source" "my_source" { - source_id = "e598287a-0d45-4578-b83a-0345516193a2" + source_id = "f844cbc0-7f65-4e5d-9847-8196e36f66cd" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_source_definition/data-source.tf b/examples/data-sources/airbyte_source_definition/data-source.tf index 94f0b74..c4cc9f2 100644 --- a/examples/data-sources/airbyte_source_definition/data-source.tf +++ b/examples/data-sources/airbyte_source_definition/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_source_definition" "my_sourcedefinition" { - source_definition_id = "0e334498-7de7-4710-bbdf-6188b86c7c05" + source_definition_id = "38de26a5-5755-4871-91c3-16fa6ed0923b" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_source_schema/data-source.tf b/examples/data-sources/airbyte_source_schema/data-source.tf index 92c4a28..801bafe 100644 --- a/examples/data-sources/airbyte_source_schema/data-source.tf +++ b/examples/data-sources/airbyte_source_schema/data-source.tf @@ -1,6 +1,6 @@ data "airbyte_source_schema" "my_sourceschema" { - connection_id = "75ad76ab-ad25-4e96-813a-8182106e4b2c" + connection_id = "ff392053-3529-44d0-addf-f687ccb9e13e" disable_cache = true - notify_schema_change = false - source_id = "663405a2-956a-4dce-a22c-210d6bb60f1f" + notify_schema_change = true + source_id = "a5e59828-7a0d-4455-b838-3a0345516193" } \ No newline at end of file diff --git a/examples/data-sources/airbyte_workspace/data-source.tf b/examples/data-sources/airbyte_workspace/data-source.tf index 31c616c..72687c2 100644 --- a/examples/data-sources/airbyte_workspace/data-source.tf +++ b/examples/data-sources/airbyte_workspace/data-source.tf @@ -1,3 +1,3 @@ data "airbyte_workspace" "my_workspace" { - workspace_id = "ea9808f3-1bb1-41a6-8314-62ad4d59ef89" + workspace_id = "a20e3344-987d-4e77-90fb-df6188b86c7c" } \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf index 2227d30..280c4a1 100644 --- a/examples/provider/provider.tf +++ b/examples/provider/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { airbyte = { source = "aballiet/airbyte-oss" - version = "1.1.1" + version = "1.2.0" } } } diff --git a/examples/resources/airbyte_connection/resource.tf b/examples/resources/airbyte_connection/resource.tf index 5918f73..1358ca4 100644 --- a/examples/resources/airbyte_connection/resource.tf +++ b/examples/resources/airbyte_connection/resource.tf @@ -7,77 +7,9 @@ resource "airbyte_connection" "my_connection" { non_breaking_changes_preference = "ignore" notify_schema_changes = false notify_schema_changes_by_email = true - operation_ids = [ - "fbb5835b-a03c-430b-b29d-f734fbd43f94", - ] - prefix = "...my_prefix..." - resource_requirements = { - cpu_limit = "...my_cpu_limit..." - cpu_request = "...my_cpu_request..." - memory_limit = "...my_memory_limit..." - memory_request = "...my_memory_request..." - } - schedule_data = { - basic_schedule = { - time_unit = "minutes" - units = 9 - } - cron = { - cron_expression = "...my_cron_expression..." - cron_time_zone = "...my_cron_time_zone..." - } - } - schedule_type = "cron" - source_catalog_id = "aa5e6b8d-d995-4b85-b38d-b9804e4cb5e1" - source_id = "451ef85f-dd64-4863-9632-1f097ee8d406" - status = "inactive" - sync_catalog = { - streams = [ - { - config = { - alias_name = "...my_alias_name..." - cursor_field = [ - "...", - ] - destination_sync_mode = "overwrite" - field_selection_enabled = true - primary_key = [ - [ - "...", - ], - ] - selected = false - selected_fields = [ - { - field_path = [ - "...", - ] - }, - ] - suggested = true - sync_mode = "incremental" - } - stream = { - default_cursor_field = [ - "...", - ] - json_schema = { - "Sausages" = "{ \"see\": \"documentation\" }" - "East" = "{ \"see\": \"documentation\" }" - } - name = "Mildred Lueilwitz" - namespace = "...my_namespace..." - source_defined_cursor = false - source_defined_primary_key = [ - [ - "...", - ], - ] - supported_sync_modes = [ - "incremental", - ] - } - }, - ] - } + prefix = "...my_prefix..." + schedule_type = "cron" + source_catalog_id = "bb5835ba-03c3-40b3-a9df-734fbd43f940" + source_id = "eaaa5e6b-8dd9-495b-85b3-8db9804e4cb5" + status = "deprecated" } \ No newline at end of file diff --git a/examples/resources/airbyte_destination/resource.tf b/examples/resources/airbyte_destination/resource.tf index 9483dbe..186144a 100644 --- a/examples/resources/airbyte_destination/resource.tf +++ b/examples/resources/airbyte_destination/resource.tf @@ -1,6 +1,6 @@ resource "airbyte_destination" "my_destination" { connection_configuration = { "user" : "charles" } - destination_definition_id = "9db62f95-525d-4bfb-8168-610013358751" - name = "Heidi Conn" - workspace_id = "625efa1b-bfa8-4d64-9f71-9d133279f15a" + destination_definition_id = "1451ef85-fdd6-4486-b963-21f097ee8d40" + name = "Willie Olson" + workspace_id = "bd3f0511-865e-4c9d-b62f-95525dbfb016" } \ No newline at end of file diff --git a/examples/resources/airbyte_destination_definition/resource.tf b/examples/resources/airbyte_destination_definition/resource.tf index 5b91787..500895e 100644 --- a/examples/resources/airbyte_destination_definition/resource.tf +++ b/examples/resources/airbyte_destination_definition/resource.tf @@ -1,31 +1,15 @@ resource "airbyte_destination_definition" "my_destinationdefinition" { - destination_definition = { - name = "Dwight Robel" - docker_repository = "...my_docker_repository..." - docker_image_tag = "...my_docker_image_tag..." - documentation_url = "https://united-consensus.biz" - icon = "...my_icon..." - resource_requirements = { - default = { - cpu_request = "...my_cpu_request..." - cpu_limit = "...my_cpu_limit..." - memory_request = "...my_memory_request..." - memory_limit = "...my_memory_limit..." - } - job_specific = [ - { - job_type = "replicate" - resource_requirements = { - cpu_request = "...my_cpu_request..." - cpu_limit = "...my_cpu_limit..." - memory_request = "...my_memory_request..." - memory_limit = "...my_memory_limit..." - } - }, - ] - } - } - scope_id = "ac9256cf-8784-4989-b0f7-7eda0554f685" - scope_type = "organization" - workspace_id = "fc353545-7d24-4426-8ff9-77c6f814b5f1" + cpu_limit = "...my_cpu_limit..." + cpu_request = "...my_cpu_request..." + docker_image_tag = "...my_docker_image_tag..." + docker_repository = "...my_docker_repository..." + documentation_url = "https://healthy-bandolier.com" + icon = "...my_icon..." + job_type = "get_spec" + memory_limit = "...my_memory_limit..." + memory_request = "...my_memory_request..." + name = "Thelma Dooley" + scope_id = "7515722b-625e-4fa1-bbfa-8d645f719d13" + scope_type = "workspace" + workspace_id = "279f15ad-8bb3-4fe3-bfac-9256cf878498" } \ No newline at end of file diff --git a/examples/resources/airbyte_operation/resource.tf b/examples/resources/airbyte_operation/resource.tf index d014604..1f6c2ac 100644 --- a/examples/resources/airbyte_operation/resource.tf +++ b/examples/resources/airbyte_operation/resource.tf @@ -1,5 +1,5 @@ resource "airbyte_operation" "my_operation" { - name = "Ms. Simon Funk" + name = "Jeff Barton" operator_configuration = { dbt = { dbt_arguments = "...my_dbt_arguments..." @@ -10,17 +10,17 @@ resource "airbyte_operation" "my_operation" { normalization = { option = "basic" } - operator_type = "normalization" + operator_type = "dbt" webhook = { dbt_cloud = { - account_id = 9 - job_id = 4 + account_id = 10 + job_id = 9 } execution_body = "...my_execution_body..." execution_url = "...my_execution_url..." - webhook_config_id = "067c0faa-27e0-4571-907b-12f607aea75f" + webhook_config_id = "a0554f68-58fc-4353-9457-d244268ff977" webhook_type = "dbtCloud" } } - workspace_id = "355b45bc-e45d-4e0c-a038-bc3c12192fc9" + workspace_id = "c6f814b5-f1dc-4406-93e6-067c0faa27e0" } \ No newline at end of file diff --git a/examples/resources/airbyte_source/resource.tf b/examples/resources/airbyte_source/resource.tf index 2f99061..1804294 100644 --- a/examples/resources/airbyte_source/resource.tf +++ b/examples/resources/airbyte_source/resource.tf @@ -1,7 +1,7 @@ resource "airbyte_source" "my_source" { connection_configuration = { "user" : "charles" } - name = "Elizabeth Johnson MD" + name = "Tamara Carroll IV" secret_id = "airbyte_oauth_workspace_0509f049-d671-48cb-8105-0a23d47e6db6_secret_e0d38206-034e-4d75-9d21-da5a99b02826_v1" - source_definition_id = "10e8de28-ee35-4676-9ccc-7d20b17eae1d" - workspace_id = "d9c43502-7c42-4c7c-9806-319146c84086" + source_definition_id = "b12f607a-ea75-4f35-9b45-bce45de0c203" + workspace_id = "8bc3c121-92fc-4920-a51b-10e8de28ee35" } \ No newline at end of file diff --git a/examples/resources/airbyte_source_definition/resource.tf b/examples/resources/airbyte_source_definition/resource.tf index fc2cb06..c314332 100644 --- a/examples/resources/airbyte_source_definition/resource.tf +++ b/examples/resources/airbyte_source_definition/resource.tf @@ -1,31 +1,15 @@ resource "airbyte_source_definition" "my_sourcedefinition" { - scope_id = "3d9d1434-d468-48b6-8221-d5f1402c7e26" - scope_type = "workspace" - source_definition = { - name = "Felicia Huels" - docker_repository = "...my_docker_repository..." - docker_image_tag = "...my_docker_image_tag..." - documentation_url = "http://unnatural-falling-out.biz" - icon = "...my_icon..." - resource_requirements = { - default = { - cpu_request = "...my_cpu_request..." - cpu_limit = "...my_cpu_limit..." - memory_request = "...my_memory_request..." - memory_limit = "...my_memory_limit..." - } - job_specific = [ - { - job_type = "replicate" - resource_requirements = { - cpu_request = "...my_cpu_request..." - cpu_limit = "...my_cpu_limit..." - memory_request = "...my_memory_request..." - memory_limit = "...my_memory_limit..." - } - }, - ] - } - } - workspace_id = "e038120e-c22a-4c97-8dbe-310dc62194f1" + cpu_limit = "...my_cpu_limit..." + cpu_request = "...my_cpu_request..." + docker_image_tag = "...my_docker_image_tag..." + docker_repository = "...my_docker_repository..." + documentation_url = "http://jam-packed-guarantee.com" + icon = "...my_icon..." + job_type = "connection_updater" + memory_limit = "...my_memory_limit..." + memory_request = "...my_memory_request..." + name = "Garrett Kirlin" + scope_id = "0b17eae1-dd9c-4435-827c-42c7cd806319" + scope_type = "workspace" + workspace_id = "46c84086-3d9d-4143-8d46-88b60221d5f1" } \ No newline at end of file diff --git a/examples/resources/airbyte_source_definition_manifest/resource.tf b/examples/resources/airbyte_source_definition_manifest/resource.tf index e8193e7..5a42202 100644 --- a/examples/resources/airbyte_source_definition_manifest/resource.tf +++ b/examples/resources/airbyte_source_definition_manifest/resource.tf @@ -3,9 +3,9 @@ resource "airbyte_source_definition_manifest" "my_sourcedefinitionmanifest" { description = "...my_description..." manifest = {} spec = {} - version = 0 + version = 3 } set_as_active_manifest = true - source_definition_id = "ed73d68a-b928-40ee-8d96-c08a642e276d" - workspace_id = "d0ab8d09-6c23-4af1-b00d-e2cba9260839" + source_definition_id = "2c7e2666-964b-41e5-8ee0-38120ec22ac9" + workspace_id = "78dbe310-dc62-4194-b112-ed73d68ab928" } \ No newline at end of file diff --git a/examples/resources/airbyte_workspace/resource.tf b/examples/resources/airbyte_workspace/resource.tf index 96c0f04..a01b0d8 100644 --- a/examples/resources/airbyte_workspace/resource.tf +++ b/examples/resources/airbyte_workspace/resource.tf @@ -1,103 +1,10 @@ resource "airbyte_workspace" "my_workspace" { - anonymous_data_collection = false + anonymous_data_collection = true default_geography = "eu" display_setup_wizard = true - email = "Nyah70@hotmail.com" - name = "Brandon Kemmer" + email = "Santa_Maggio@hotmail.com" + name = "Penny Padberg" news = true - notifications = [ - { - customerio_configuration = {} - notification_type = "customerio" - send_on_failure = true - send_on_success = false - slack_configuration = { - webhook = "...my_webhook..." - } - }, - ] - notification_settings = { - send_on_breaking_change_syncs_disabled = { - customerio_configuration = {} - notification_type = [ - "slack", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_breaking_change_warning = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_connection_update = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_connection_update_action_required = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_failure = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_success = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_sync_disabled = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - send_on_sync_disabled_warning = { - customerio_configuration = {} - notification_type = [ - "customerio", - ] - slack_configuration = { - webhook = "...my_webhook..." - } - } - } - organization_id = "d401e41a-e1e8-4142-8fc7-67202da61c2e" - security_updates = false - webhook_configs = [ - { - auth_token = "...my_auth_token..." - id = "39100781-f2da-4dfe-b55f-97cbac4a9fe3" - name = "Eloise Senger" - validation_url = "...my_validation_url..." - }, - ] + organization_id = "e276dd0a-b8d0-496c-a3af-1300de2cba92" + security_updates = false } \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index af5261b..fcc37f8 100755 --- a/gen.yaml +++ b/gen.yaml @@ -1,19 +1,17 @@ -configVersion: 1.0.0 +configVersion: 2.0.0 generation: - comments: {} sdkClassName: SDK maintainOpenAPIOrder: true usageSnippets: optionalPropertyRendering: withExample -features: - terraform: - constsAndDefaults: 0.1.2 - core: 3.6.0 - deprecations: 2.81.1 - globalSecurity: 2.81.2 - globalServerURLs: 2.82.1 + fixes: + nameResolutionDec2023: false + parameterOrderingFeb2024: false + requestResponseComponentNamesFeb2024: false + auth: + oAuth2ClientCredentialsEnabled: false terraform: - version: 1.1.1 + version: 1.2.0 author: aballiet imports: option: openapi diff --git a/go.mod b/go.mod index d7332cd..1734f8a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/aballiet/terraform-provider-airbyte -go 1.18 +go 1.20 require ( github.com/cenkalti/backoff/v4 v4.2.0 diff --git a/internal/planmodifiers/boolplanmodifier/suppress_diff.go b/internal/planmodifiers/boolplanmodifier/suppress_diff.go index 9999e49..9237f5b 100644 --- a/internal/planmodifiers/boolplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/boolplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Bool { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Bool { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/float64planmodifier/suppress_diff.go b/internal/planmodifiers/float64planmodifier/suppress_diff.go index f45f281..c859931 100644 --- a/internal/planmodifiers/float64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/float64planmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Float64 { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Float64 { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/int64planmodifier/suppress_diff.go b/internal/planmodifiers/int64planmodifier/suppress_diff.go index dbb1dd4..08e4094 100644 --- a/internal/planmodifiers/int64planmodifier/suppress_diff.go +++ b/internal/planmodifiers/int64planmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Int64 { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Int64 { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/listplanmodifier/suppress_diff.go b/internal/planmodifiers/listplanmodifier/suppress_diff.go index 48d72d4..f1bcecc 100644 --- a/internal/planmodifiers/listplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/listplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.List { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.List { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/mapplanmodifier/suppress_diff.go b/internal/planmodifiers/mapplanmodifier/suppress_diff.go index fa51fa5..d09fca3 100644 --- a/internal/planmodifiers/mapplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/mapplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Map { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Map { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/numberplanmodifier/suppress_diff.go b/internal/planmodifiers/numberplanmodifier/suppress_diff.go index a6823de..f01d426 100644 --- a/internal/planmodifiers/numberplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/numberplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Number { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Number { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/objectplanmodifier/suppress_diff.go b/internal/planmodifiers/objectplanmodifier/suppress_diff.go index 12e575a..0c49d60 100644 --- a/internal/planmodifiers/objectplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/objectplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Object { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Object { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/setplanmodifier/suppress_diff.go b/internal/planmodifiers/setplanmodifier/suppress_diff.go index 24c9866..91143e1 100644 --- a/internal/planmodifiers/setplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/setplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.Set { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.Set { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/planmodifiers/stringplanmodifier/suppress_diff.go b/internal/planmodifiers/stringplanmodifier/suppress_diff.go index a2caa32..33361de 100644 --- a/internal/planmodifiers/stringplanmodifier/suppress_diff.go +++ b/internal/planmodifiers/stringplanmodifier/suppress_diff.go @@ -9,13 +9,22 @@ import ( "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() planmodifier.String { - return suppressDiff{} +func SuppressDiff(strategy int) planmodifier.String { + return suppressDiff{ + strategy: strategy, + } } // suppressDiff implements the plan modifier. -type suppressDiff struct{} +type suppressDiff struct { + strategy int +} // Description returns a human-readable description of the plan modifier. func (m suppressDiff) Description(_ context.Context) string { diff --git a/internal/provider/connection_data_source.go b/internal/provider/connection_data_source.go index 62b488f..03b78e8 100644 --- a/internal/provider/connection_data_source.go +++ b/internal/provider/connection_data_source.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -79,14 +78,12 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema Computed: true, }, "namespace_definition": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["source", "destination", "customformat"]` + "\n" + - `Method used for computing final namespace in destination`, + Computed: true, + Description: `Method used for computing final namespace in destination. must be one of ["source", "destination", "customformat"]`, }, "namespace_format": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `Default: null` + "\n" + - `Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'.`, + Computed: true, + Description: `Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'.`, }, "non_breaking_changes_preference": schema.StringAttribute{ Computed: true, @@ -109,18 +106,18 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema "resource_requirements": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - Computed: true, - }, "cpu_limit": schema.StringAttribute{ Computed: true, }, - "memory_request": schema.StringAttribute{ + "cpu_request": schema.StringAttribute{ Computed: true, }, "memory_limit": schema.StringAttribute{ Computed: true, }, + "memory_request": schema.StringAttribute{ + Computed: true, + }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, @@ -154,9 +151,8 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema Description: `schedule for when the the connection should run, per the schedule type`, }, "schedule_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["manual", "basic", "cron"]` + "\n" + - `determine how the schedule data should be interpreted`, + Computed: true, + Description: `determine how the schedule data should be interpreted. must be one of ["manual", "basic", "cron"]`, }, "source_catalog_id": schema.StringAttribute{ Computed: true, @@ -165,9 +161,8 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema Computed: true, }, "status": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["active", "inactive", "deprecated"]` + "\n" + - `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced.`, + Computed: true, + Description: `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced. must be one of ["active", "inactive", "deprecated"]`, }, "sync_catalog": schema.SingleNestedAttribute{ Computed: true, @@ -176,51 +171,12 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "stream": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - Computed: true, - Description: `Stream's name.`, - }, - "json_schema": schema.MapAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Stream schema using Json Schema specs.`, - }, - "supported_sync_modes": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "source_defined_cursor": schema.BoolAttribute{ - Computed: true, - Description: `If the source defines the cursor field, then any other cursor field inputs will be ignored. If it does not, either the user_provided one is used, or the default one is used as a backup.`, - }, - "default_cursor_field": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Path to the field that will be used to determine if a record is new or modified since the last sync. If not provided by the source, the end user will have to specify the comparable themselves.`, - }, - "source_defined_primary_key": schema.ListAttribute{ - Computed: true, - ElementType: types.ListType{ - ElemType: types.StringType, - }, - Description: `If the source defines the primary key, paths to the fields that will be used as a primary key. If not provided by the source, the end user will have to specify the primary key themselves.`, - }, - "namespace": schema.StringAttribute{ - Computed: true, - Description: `Optional Source-defined namespace. Airbyte streams from the same sources should have the same namespace. Currently only used by JDBC destinations to determine what schema to write to.`, - }, - }, - Description: `the immutable schema defined by the source`, - }, "config": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "sync_mode": schema.StringAttribute{ + "alias_name": schema.StringAttribute{ Computed: true, - Description: `must be one of ["full_refresh", "incremental"]`, + Description: `Alias name to the stream to be used in the destination`, }, "cursor_field": schema.ListAttribute{ Computed: true, @@ -231,6 +187,10 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema Computed: true, Description: `must be one of ["append", "overwrite", "append_dedup"]`, }, + "field_selection_enabled": schema.BoolAttribute{ + Computed: true, + Description: `Whether field selection should be enabled. If this is true, only the properties in ` + "`" + `selectedFields` + "`" + ` will be included.`, + }, "primary_key": schema.ListAttribute{ Computed: true, ElementType: types.ListType{ @@ -238,22 +198,10 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema }, Description: `Paths to the fields that will be used as primary key. This field is REQUIRED if ` + "`" + `destination_sync_mode` + "`" + ` is ` + "`" + `*_dedup` + "`" + `. Otherwise it is ignored.`, }, - "alias_name": schema.StringAttribute{ - Computed: true, - Description: `Alias name to the stream to be used in the destination`, - }, "selected": schema.BoolAttribute{ Computed: true, Description: `If this is true, the stream is selected with all of its properties. For new connections, this considers if the stream is suggested or not`, }, - "suggested": schema.BoolAttribute{ - Computed: true, - Description: `Does the connector suggest that this stream be enabled by default?`, - }, - "field_selection_enabled": schema.BoolAttribute{ - Computed: true, - Description: `Whether field selection should be enabled. If this is true, only the properties in ` + "`" + `selectedFields` + "`" + ` will be included.`, - }, "selected_fields": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ @@ -266,9 +214,56 @@ func (r *ConnectionDataSource) Schema(ctx context.Context, req datasource.Schema }, Description: `Paths to the fields that will be included in the configured catalog. This must be set if ` + "`" + `fieldSelectedEnabled` + "`" + ` is set. An empty list indicates that no properties will be included.`, }, + "suggested": schema.BoolAttribute{ + Computed: true, + Description: `Does the connector suggest that this stream be enabled by default?`, + }, + "sync_mode": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["full_refresh", "incremental"]`, + }, }, Description: `the mutable part of the stream to configure the destination`, }, + "stream": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "default_cursor_field": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `Path to the field that will be used to determine if a record is new or modified since the last sync. If not provided by the source, the end user will have to specify the comparable themselves.`, + }, + "json_schema": schema.MapAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `Stream schema using Json Schema specs.`, + }, + "name": schema.StringAttribute{ + Computed: true, + Description: `Stream's name.`, + }, + "namespace": schema.StringAttribute{ + Computed: true, + Description: `Optional Source-defined namespace. Airbyte streams from the same sources should have the same namespace. Currently only used by JDBC destinations to determine what schema to write to.`, + }, + "source_defined_cursor": schema.BoolAttribute{ + Computed: true, + Description: `If the source defines the cursor field, then any other cursor field inputs will be ignored. If it does not, either the user_provided one is used, or the default one is used as a backup.`, + }, + "source_defined_primary_key": schema.ListAttribute{ + Computed: true, + ElementType: types.ListType{ + ElemType: types.StringType, + }, + Description: `If the source defines the primary key, paths to the fields that will be used as a primary key. If not provided by the source, the end user will have to specify the primary key themselves.`, + }, + "supported_sync_modes": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + }, + }, + Description: `the immutable schema defined by the source`, + }, }, }, }, @@ -344,7 +339,7 @@ func (r *ConnectionDataSource) Read(ctx context.Context, req datasource.ReadRequ resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.ConnectionRead) + data.RefreshFromSharedConnectionRead(res.ConnectionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/connection_data_source_sdk.go b/internal/provider/connection_data_source_sdk.go index a79a2f0..4e2fff2 100644 --- a/internal/provider/connection_data_source_sdk.go +++ b/internal/provider/connection_data_source_sdk.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.ConnectionRead) { +func (r *ConnectionDataSourceModel) RefreshFromSharedConnectionRead(resp *shared.ConnectionRead) { r.BreakingChange = types.BoolValue(resp.BreakingChange) r.ConnectionID = types.StringValue(resp.ConnectionID) r.DestinationID = types.StringValue(resp.DestinationID) @@ -23,59 +23,27 @@ func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.Connecti } else { r.NamespaceDefinition = types.StringNull() } - if resp.NamespaceFormat != nil { - r.NamespaceFormat = types.StringValue(*resp.NamespaceFormat) - } else { - r.NamespaceFormat = types.StringNull() - } + r.NamespaceFormat = types.StringPointerValue(resp.NamespaceFormat) if resp.NonBreakingChangesPreference != nil { r.NonBreakingChangesPreference = types.StringValue(string(*resp.NonBreakingChangesPreference)) } else { r.NonBreakingChangesPreference = types.StringNull() } - if resp.NotifySchemaChanges != nil { - r.NotifySchemaChanges = types.BoolValue(*resp.NotifySchemaChanges) - } else { - r.NotifySchemaChanges = types.BoolNull() - } - if resp.NotifySchemaChangesByEmail != nil { - r.NotifySchemaChangesByEmail = types.BoolValue(*resp.NotifySchemaChangesByEmail) - } else { - r.NotifySchemaChangesByEmail = types.BoolNull() - } + r.NotifySchemaChanges = types.BoolPointerValue(resp.NotifySchemaChanges) + r.NotifySchemaChangesByEmail = types.BoolPointerValue(resp.NotifySchemaChangesByEmail) r.OperationIds = nil for _, v := range resp.OperationIds { r.OperationIds = append(r.OperationIds, types.StringValue(v)) } - if resp.Prefix != nil { - r.Prefix = types.StringValue(*resp.Prefix) - } else { - r.Prefix = types.StringNull() - } + r.Prefix = types.StringPointerValue(resp.Prefix) if resp.ResourceRequirements == nil { r.ResourceRequirements = nil } else { r.ResourceRequirements = &ResourceRequirements{} - if resp.ResourceRequirements.CPURequest != nil { - r.ResourceRequirements.CPURequest = types.StringValue(*resp.ResourceRequirements.CPURequest) - } else { - r.ResourceRequirements.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.CPULimit != nil { - r.ResourceRequirements.CPULimit = types.StringValue(*resp.ResourceRequirements.CPULimit) - } else { - r.ResourceRequirements.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.MemoryRequest != nil { - r.ResourceRequirements.MemoryRequest = types.StringValue(*resp.ResourceRequirements.MemoryRequest) - } else { - r.ResourceRequirements.MemoryRequest = types.StringNull() - } - if resp.ResourceRequirements.MemoryLimit != nil { - r.ResourceRequirements.MemoryLimit = types.StringValue(*resp.ResourceRequirements.MemoryLimit) - } else { - r.ResourceRequirements.MemoryLimit = types.StringNull() - } + r.ResourceRequirements.CPULimit = types.StringPointerValue(resp.ResourceRequirements.CPULimit) + r.ResourceRequirements.CPURequest = types.StringPointerValue(resp.ResourceRequirements.CPURequest) + r.ResourceRequirements.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.MemoryLimit) + r.ResourceRequirements.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.MemoryRequest) } if resp.ScheduleData == nil { r.ScheduleData = nil @@ -101,11 +69,7 @@ func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.Connecti } else { r.ScheduleType = types.StringNull() } - if resp.SourceCatalogID != nil { - r.SourceCatalogID = types.StringValue(*resp.SourceCatalogID) - } else { - r.SourceCatalogID = types.StringNull() - } + r.SourceCatalogID = types.StringPointerValue(resp.SourceCatalogID) r.SourceID = types.StringValue(resp.SourceID) r.Status = types.StringValue(string(resp.Status)) if len(r.SyncCatalog.Streams) > len(resp.SyncCatalog.Streams) { @@ -113,56 +77,17 @@ func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.Connecti } for streamsCount, streamsItem := range resp.SyncCatalog.Streams { var streams1 AirbyteStreamAndConfiguration - if streamsItem.Stream == nil { - streams1.Stream = nil - } else { - streams1.Stream = &AirbyteStream{} - streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) - if streams1.Stream.JSONSchema == nil && len(streamsItem.Stream.JSONSchema) > 0 { - streams1.Stream.JSONSchema = make(map[string]types.String) - for key, value := range streamsItem.Stream.JSONSchema { - result, _ := json.Marshal(value) - streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) - } - } - streams1.Stream.SupportedSyncModes = nil - for _, v := range streamsItem.Stream.SupportedSyncModes { - streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) - } - if streamsItem.Stream.SourceDefinedCursor != nil { - streams1.Stream.SourceDefinedCursor = types.BoolValue(*streamsItem.Stream.SourceDefinedCursor) - } else { - streams1.Stream.SourceDefinedCursor = types.BoolNull() - } - streams1.Stream.DefaultCursorField = nil - for _, v := range streamsItem.Stream.DefaultCursorField { - streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) - } - streams1.Stream.SourceDefinedPrimaryKey = nil - for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { - var sourceDefinedPrimaryKey1 []types.String - sourceDefinedPrimaryKey1 = nil - for _, v := range sourceDefinedPrimaryKeyItem { - sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) - } - streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) - } - if streamsItem.Stream.Namespace != nil { - streams1.Stream.Namespace = types.StringValue(*streamsItem.Stream.Namespace) - } else { - streams1.Stream.Namespace = types.StringNull() - } - } if streamsItem.Config == nil { streams1.Config = nil } else { streams1.Config = &AirbyteStreamConfiguration{} - streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) + streams1.Config.AliasName = types.StringPointerValue(streamsItem.Config.AliasName) streams1.Config.CursorField = nil for _, v := range streamsItem.Config.CursorField { streams1.Config.CursorField = append(streams1.Config.CursorField, types.StringValue(v)) } streams1.Config.DestinationSyncMode = types.StringValue(string(streamsItem.Config.DestinationSyncMode)) + streams1.Config.FieldSelectionEnabled = types.BoolPointerValue(streamsItem.Config.FieldSelectionEnabled) streams1.Config.PrimaryKey = nil for _, primaryKeyItem := range streamsItem.Config.PrimaryKey { var primaryKey1 []types.String @@ -172,29 +97,7 @@ func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.Connecti } streams1.Config.PrimaryKey = append(streams1.Config.PrimaryKey, primaryKey1) } - if streamsItem.Config.AliasName != nil { - streams1.Config.AliasName = types.StringValue(*streamsItem.Config.AliasName) - } else { - streams1.Config.AliasName = types.StringNull() - } - if streamsItem.Config.Selected != nil { - streams1.Config.Selected = types.BoolValue(*streamsItem.Config.Selected) - } else { - streams1.Config.Selected = types.BoolNull() - } - if streamsItem.Config.Suggested != nil { - streams1.Config.Suggested = types.BoolValue(*streamsItem.Config.Suggested) - } else { - streams1.Config.Suggested = types.BoolNull() - } - if streamsItem.Config.FieldSelectionEnabled != nil { - streams1.Config.FieldSelectionEnabled = types.BoolValue(*streamsItem.Config.FieldSelectionEnabled) - } else { - streams1.Config.FieldSelectionEnabled = types.BoolNull() - } - if len(streams1.Config.SelectedFields) > len(streamsItem.Config.SelectedFields) { - streams1.Config.SelectedFields = streams1.Config.SelectedFields[:len(streamsItem.Config.SelectedFields)] - } + streams1.Config.Selected = types.BoolPointerValue(streamsItem.Config.Selected) for selectedFieldsCount, selectedFieldsItem := range streamsItem.Config.SelectedFields { var selectedFields1 SelectedFieldInfo selectedFields1.FieldPath = nil @@ -207,17 +110,47 @@ func (r *ConnectionDataSourceModel) RefreshFromGetResponse(resp *shared.Connecti streams1.Config.SelectedFields[selectedFieldsCount].FieldPath = selectedFields1.FieldPath } } + streams1.Config.Suggested = types.BoolPointerValue(streamsItem.Config.Suggested) + streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) + } + if streamsItem.Stream == nil { + streams1.Stream = nil + } else { + streams1.Stream = &AirbyteStream{} + streams1.Stream.DefaultCursorField = nil + for _, v := range streamsItem.Stream.DefaultCursorField { + streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) + } + if len(streamsItem.Stream.JSONSchema) > 0 { + streams1.Stream.JSONSchema = make(map[string]types.String) + for key, value := range streamsItem.Stream.JSONSchema { + result, _ := json.Marshal(value) + streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) + } + } + streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) + streams1.Stream.Namespace = types.StringPointerValue(streamsItem.Stream.Namespace) + streams1.Stream.SourceDefinedCursor = types.BoolPointerValue(streamsItem.Stream.SourceDefinedCursor) + streams1.Stream.SourceDefinedPrimaryKey = nil + for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { + var sourceDefinedPrimaryKey1 []types.String + sourceDefinedPrimaryKey1 = nil + for _, v := range sourceDefinedPrimaryKeyItem { + sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) + } + streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) + } + streams1.Stream.SupportedSyncModes = nil + for _, v := range streamsItem.Stream.SupportedSyncModes { + streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) + } } if streamsCount+1 > len(r.SyncCatalog.Streams) { r.SyncCatalog.Streams = append(r.SyncCatalog.Streams, streams1) } else { - r.SyncCatalog.Streams[streamsCount].Stream = streams1.Stream r.SyncCatalog.Streams[streamsCount].Config = streams1.Config + r.SyncCatalog.Streams[streamsCount].Stream = streams1.Stream } } - if resp.WorkspaceID != nil { - r.WorkspaceID = types.StringValue(*resp.WorkspaceID) - } else { - r.WorkspaceID = types.StringNull() - } + r.WorkspaceID = types.StringPointerValue(resp.WorkspaceID) } diff --git a/internal/provider/connection_resource.go b/internal/provider/connection_resource.go index 0944677..44202d5 100644 --- a/internal/provider/connection_resource.go +++ b/internal/provider/connection_resource.go @@ -5,10 +5,13 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/aballiet/terraform-provider-airbyte/internal/validators" + speakeasy_int64validators "github.com/aballiet/terraform-provider-airbyte/internal/validators/int64validators" + speakeasy_listvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/listvalidators" + speakeasy_stringvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" @@ -75,9 +78,11 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, "destination_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "geography": schema.StringAttribute{ Computed: true, @@ -97,10 +102,9 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Description: `Optional name of the connection`, }, "namespace_definition": schema.StringAttribute{ - Computed: true, - Optional: true, - MarkdownDescription: `must be one of ["source", "destination", "customformat"]` + "\n" + - `Method used for computing final namespace in destination`, + Computed: true, + Optional: true, + Description: `Method used for computing final namespace in destination. must be one of ["source", "destination", "customformat"]`, Validators: []validator.String{ stringvalidator.OneOf( "source", @@ -110,10 +114,9 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, }, "namespace_format": schema.StringAttribute{ - Computed: true, - Optional: true, - MarkdownDescription: `Default: null` + "\n" + - `Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'.`, + Computed: true, + Optional: true, + Description: `Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'. Default: null`, }, "non_breaking_changes_preference": schema.StringAttribute{ Computed: true, @@ -178,9 +181,11 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Optional: true, Attributes: map[string]schema.Attribute{ "time_unit": schema.StringAttribute{ - Required: true, - Description: `must be one of ["minutes", "hours", "days", "weeks", "months"]`, + Computed: true, + Optional: true, + Description: `Not Null; must be one of ["minutes", "hours", "days", "weeks", "months"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "minutes", "hours", @@ -191,7 +196,12 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, }, "units": schema.Int64Attribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.Int64{ + speakeasy_int64validators.NotNull(), + }, }, }, }, @@ -200,10 +210,20 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Optional: true, Attributes: map[string]schema.Attribute{ "cron_expression": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, "cron_time_zone": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -211,10 +231,9 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Description: `schedule for when the the connection should run, per the schedule type`, }, "schedule_type": schema.StringAttribute{ - Computed: true, - Optional: true, - MarkdownDescription: `must be one of ["manual", "basic", "cron"]` + "\n" + - `determine how the schedule data should be interpreted`, + Computed: true, + Optional: true, + Description: `determine how the schedule data should be interpreted. must be one of ["manual", "basic", "cron"]`, Validators: []validator.String{ stringvalidator.OneOf( "manual", @@ -229,14 +248,15 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, "source_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "status": schema.StringAttribute{ - Required: true, - MarkdownDescription: `must be one of ["active", "inactive", "deprecated"]` + "\n" + - `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced.`, + Required: true, + Description: `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced. must be one of ["active", "inactive", "deprecated"]`, Validators: []validator.String{ stringvalidator.OneOf( "active", @@ -250,7 +270,8 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Optional: true, Attributes: map[string]schema.Attribute{ "streams": schema.ListNestedAttribute{ - Required: true, + Computed: true, + Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "config": schema.SingleNestedAttribute{ @@ -269,9 +290,11 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Description: `Path to the field that will be used to determine if a record is new or modified since the last sync. This field is REQUIRED if ` + "`" + `sync_mode` + "`" + ` is ` + "`" + `incremental` + "`" + `. Otherwise it is ignored.`, }, "destination_sync_mode": schema.StringAttribute{ - Required: true, - Description: `must be one of ["append", "overwrite", "append_dedup"]`, + Computed: true, + Optional: true, + Description: `Not Null; must be one of ["append", "overwrite", "append_dedup"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "append", "overwrite", @@ -317,9 +340,11 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ Description: `Does the connector suggest that this stream be enabled by default?`, }, "sync_mode": schema.StringAttribute{ - Required: true, - Description: `must be one of ["full_refresh", "incremental"]`, + Computed: true, + Optional: true, + Description: `Not Null; must be one of ["full_refresh", "incremental"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "full_refresh", "incremental", @@ -349,8 +374,12 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, }, "name": schema.StringAttribute{ - Required: true, - Description: `Stream's name.`, + Computed: true, + Optional: true, + Description: `Stream's name. Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, "namespace": schema.StringAttribute{ Computed: true, @@ -380,6 +409,10 @@ func (r *ConnectionResource) Schema(ctx context.Context, req resource.SchemaRequ }, }, }, + Description: `Not Null`, + Validators: []validator.List{ + speakeasy_listvalidators.NotNull(), + }, }, }, Description: `describes the available schema (catalog).`, @@ -413,14 +446,14 @@ func (r *ConnectionResource) Configure(ctx context.Context, req resource.Configu func (r *ConnectionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *ConnectionResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -429,7 +462,7 @@ func (r *ConnectionResource) Create(ctx context.Context, req resource.CreateRequ return } - request := *data.ToCreateSDKType() + request := *data.ToSharedConnectionCreate() res, err := r.client.Connection.CreateConnection(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -450,7 +483,8 @@ func (r *ConnectionResource) Create(ctx context.Context, req resource.CreateRequ resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.ConnectionRead) + data.RefreshFromSharedConnectionRead(res.ConnectionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -498,7 +532,7 @@ func (r *ConnectionResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.ConnectionRead) + data.RefreshFromSharedConnectionRead(res.ConnectionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -506,12 +540,19 @@ func (r *ConnectionResource) Read(ctx context.Context, req resource.ReadRequest, func (r *ConnectionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *ConnectionResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + request := *data.ToSharedConnectionUpdate() res, err := r.client.Connection.UpdateConnection(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -532,7 +573,8 @@ func (r *ConnectionResource) Update(ctx context.Context, req resource.UpdateRequ resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.ConnectionRead) + data.RefreshFromSharedConnectionRead(res.ConnectionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/connection_resource_sdk.go b/internal/provider/connection_resource_sdk.go index f8b9582..152bfb4 100644 --- a/internal/provider/connection_resource_sdk.go +++ b/internal/provider/connection_resource_sdk.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *ConnectionResourceModel) ToCreateSDKType() *shared.ConnectionCreate { +func (r *ConnectionResourceModel) ToSharedConnectionCreate() *shared.ConnectionCreate { name := new(string) if !r.Name.IsUnknown() && !r.Name.IsNull() { *name = r.Name.ValueString() @@ -278,12 +278,157 @@ func (r *ConnectionResourceModel) ToCreateSDKType() *shared.ConnectionCreate { return &out } -func (r *ConnectionResourceModel) ToGetSDKType() *shared.ConnectionCreate { - out := r.ToCreateSDKType() - return out +func (r *ConnectionResourceModel) RefreshFromSharedConnectionRead(resp *shared.ConnectionRead) { + r.BreakingChange = types.BoolValue(resp.BreakingChange) + r.ConnectionID = types.StringValue(resp.ConnectionID) + r.DestinationID = types.StringValue(resp.DestinationID) + if resp.Geography != nil { + r.Geography = types.StringValue(string(*resp.Geography)) + } else { + r.Geography = types.StringNull() + } + r.Name = types.StringValue(resp.Name) + if resp.NamespaceDefinition != nil { + r.NamespaceDefinition = types.StringValue(string(*resp.NamespaceDefinition)) + } else { + r.NamespaceDefinition = types.StringNull() + } + r.NamespaceFormat = types.StringPointerValue(resp.NamespaceFormat) + if resp.NonBreakingChangesPreference != nil { + r.NonBreakingChangesPreference = types.StringValue(string(*resp.NonBreakingChangesPreference)) + } else { + r.NonBreakingChangesPreference = types.StringNull() + } + r.NotifySchemaChanges = types.BoolPointerValue(resp.NotifySchemaChanges) + r.NotifySchemaChangesByEmail = types.BoolPointerValue(resp.NotifySchemaChangesByEmail) + r.OperationIds = nil + for _, v := range resp.OperationIds { + r.OperationIds = append(r.OperationIds, types.StringValue(v)) + } + r.Prefix = types.StringPointerValue(resp.Prefix) + if resp.ResourceRequirements == nil { + r.ResourceRequirements = nil + } else { + r.ResourceRequirements = &ResourceRequirements{} + r.ResourceRequirements.CPULimit = types.StringPointerValue(resp.ResourceRequirements.CPULimit) + r.ResourceRequirements.CPURequest = types.StringPointerValue(resp.ResourceRequirements.CPURequest) + r.ResourceRequirements.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.MemoryLimit) + r.ResourceRequirements.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.MemoryRequest) + } + if resp.ScheduleData == nil { + r.ScheduleData = nil + } else { + r.ScheduleData = &ConnectionScheduleData{} + if resp.ScheduleData.BasicSchedule == nil { + r.ScheduleData.BasicSchedule = nil + } else { + r.ScheduleData.BasicSchedule = &BasicSchedule{} + r.ScheduleData.BasicSchedule.TimeUnit = types.StringValue(string(resp.ScheduleData.BasicSchedule.TimeUnit)) + r.ScheduleData.BasicSchedule.Units = types.Int64Value(resp.ScheduleData.BasicSchedule.Units) + } + if resp.ScheduleData.Cron == nil { + r.ScheduleData.Cron = nil + } else { + r.ScheduleData.Cron = &Cron{} + r.ScheduleData.Cron.CronExpression = types.StringValue(resp.ScheduleData.Cron.CronExpression) + r.ScheduleData.Cron.CronTimeZone = types.StringValue(resp.ScheduleData.Cron.CronTimeZone) + } + } + if resp.ScheduleType != nil { + r.ScheduleType = types.StringValue(string(*resp.ScheduleType)) + } else { + r.ScheduleType = types.StringNull() + } + r.SourceCatalogID = types.StringPointerValue(resp.SourceCatalogID) + r.SourceID = types.StringValue(resp.SourceID) + r.Status = types.StringValue(string(resp.Status)) + if r.SyncCatalog == nil { + r.SyncCatalog = &AirbyteCatalog{} + } + if len(r.SyncCatalog.Streams) > len(resp.SyncCatalog.Streams) { + r.SyncCatalog.Streams = r.SyncCatalog.Streams[:len(resp.SyncCatalog.Streams)] + } + for streamsCount, streamsItem := range resp.SyncCatalog.Streams { + var streams1 AirbyteStreamAndConfiguration + if streamsItem.Config == nil { + streams1.Config = nil + } else { + streams1.Config = &AirbyteStreamConfiguration{} + streams1.Config.AliasName = types.StringPointerValue(streamsItem.Config.AliasName) + streams1.Config.CursorField = nil + for _, v := range streamsItem.Config.CursorField { + streams1.Config.CursorField = append(streams1.Config.CursorField, types.StringValue(v)) + } + streams1.Config.DestinationSyncMode = types.StringValue(string(streamsItem.Config.DestinationSyncMode)) + streams1.Config.FieldSelectionEnabled = types.BoolPointerValue(streamsItem.Config.FieldSelectionEnabled) + streams1.Config.PrimaryKey = nil + for _, primaryKeyItem := range streamsItem.Config.PrimaryKey { + var primaryKey1 []types.String + primaryKey1 = nil + for _, v := range primaryKeyItem { + primaryKey1 = append(primaryKey1, types.StringValue(v)) + } + streams1.Config.PrimaryKey = append(streams1.Config.PrimaryKey, primaryKey1) + } + streams1.Config.Selected = types.BoolPointerValue(streamsItem.Config.Selected) + for selectedFieldsCount, selectedFieldsItem := range streamsItem.Config.SelectedFields { + var selectedFields1 SelectedFieldInfo + selectedFields1.FieldPath = nil + for _, v := range selectedFieldsItem.FieldPath { + selectedFields1.FieldPath = append(selectedFields1.FieldPath, types.StringValue(v)) + } + if selectedFieldsCount+1 > len(streams1.Config.SelectedFields) { + streams1.Config.SelectedFields = append(streams1.Config.SelectedFields, selectedFields1) + } else { + streams1.Config.SelectedFields[selectedFieldsCount].FieldPath = selectedFields1.FieldPath + } + } + streams1.Config.Suggested = types.BoolPointerValue(streamsItem.Config.Suggested) + streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) + } + if streamsItem.Stream == nil { + streams1.Stream = nil + } else { + streams1.Stream = &AirbyteStream{} + streams1.Stream.DefaultCursorField = nil + for _, v := range streamsItem.Stream.DefaultCursorField { + streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) + } + if len(streamsItem.Stream.JSONSchema) > 0 { + streams1.Stream.JSONSchema = make(map[string]types.String) + for key, value := range streamsItem.Stream.JSONSchema { + result, _ := json.Marshal(value) + streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) + } + } + streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) + streams1.Stream.Namespace = types.StringPointerValue(streamsItem.Stream.Namespace) + streams1.Stream.SourceDefinedCursor = types.BoolPointerValue(streamsItem.Stream.SourceDefinedCursor) + streams1.Stream.SourceDefinedPrimaryKey = nil + for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { + var sourceDefinedPrimaryKey1 []types.String + sourceDefinedPrimaryKey1 = nil + for _, v := range sourceDefinedPrimaryKeyItem { + sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) + } + streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) + } + streams1.Stream.SupportedSyncModes = nil + for _, v := range streamsItem.Stream.SupportedSyncModes { + streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) + } + } + if streamsCount+1 > len(r.SyncCatalog.Streams) { + r.SyncCatalog.Streams = append(r.SyncCatalog.Streams, streams1) + } else { + r.SyncCatalog.Streams[streamsCount].Config = streams1.Config + r.SyncCatalog.Streams[streamsCount].Stream = streams1.Stream + } + } + r.WorkspaceID = types.StringPointerValue(resp.WorkspaceID) } -func (r *ConnectionResourceModel) ToUpdateSDKType() *shared.ConnectionUpdate { +func (r *ConnectionResourceModel) ToSharedConnectionUpdate() *shared.ConnectionUpdate { connectionID := r.ConnectionID.ValueString() namespaceDefinition := new(shared.NamespaceDefinitionType) if !r.NamespaceDefinition.IsUnknown() && !r.NamespaceDefinition.IsNull() { @@ -562,233 +707,3 @@ func (r *ConnectionResourceModel) ToUpdateSDKType() *shared.ConnectionUpdate { } return &out } - -func (r *ConnectionResourceModel) ToDeleteSDKType() *shared.ConnectionCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *ConnectionResourceModel) RefreshFromGetResponse(resp *shared.ConnectionRead) { - r.BreakingChange = types.BoolValue(resp.BreakingChange) - r.ConnectionID = types.StringValue(resp.ConnectionID) - r.DestinationID = types.StringValue(resp.DestinationID) - if resp.Geography != nil { - r.Geography = types.StringValue(string(*resp.Geography)) - } else { - r.Geography = types.StringNull() - } - r.Name = types.StringValue(resp.Name) - if resp.NamespaceDefinition != nil { - r.NamespaceDefinition = types.StringValue(string(*resp.NamespaceDefinition)) - } else { - r.NamespaceDefinition = types.StringNull() - } - if resp.NamespaceFormat != nil { - r.NamespaceFormat = types.StringValue(*resp.NamespaceFormat) - } else { - r.NamespaceFormat = types.StringNull() - } - if resp.NonBreakingChangesPreference != nil { - r.NonBreakingChangesPreference = types.StringValue(string(*resp.NonBreakingChangesPreference)) - } else { - r.NonBreakingChangesPreference = types.StringNull() - } - if resp.NotifySchemaChanges != nil { - r.NotifySchemaChanges = types.BoolValue(*resp.NotifySchemaChanges) - } else { - r.NotifySchemaChanges = types.BoolNull() - } - if resp.NotifySchemaChangesByEmail != nil { - r.NotifySchemaChangesByEmail = types.BoolValue(*resp.NotifySchemaChangesByEmail) - } else { - r.NotifySchemaChangesByEmail = types.BoolNull() - } - r.OperationIds = nil - for _, v := range resp.OperationIds { - r.OperationIds = append(r.OperationIds, types.StringValue(v)) - } - if resp.Prefix != nil { - r.Prefix = types.StringValue(*resp.Prefix) - } else { - r.Prefix = types.StringNull() - } - if resp.ResourceRequirements == nil { - r.ResourceRequirements = nil - } else { - r.ResourceRequirements = &ResourceRequirements{} - if resp.ResourceRequirements.CPULimit != nil { - r.ResourceRequirements.CPULimit = types.StringValue(*resp.ResourceRequirements.CPULimit) - } else { - r.ResourceRequirements.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.CPURequest != nil { - r.ResourceRequirements.CPURequest = types.StringValue(*resp.ResourceRequirements.CPURequest) - } else { - r.ResourceRequirements.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.MemoryLimit != nil { - r.ResourceRequirements.MemoryLimit = types.StringValue(*resp.ResourceRequirements.MemoryLimit) - } else { - r.ResourceRequirements.MemoryLimit = types.StringNull() - } - if resp.ResourceRequirements.MemoryRequest != nil { - r.ResourceRequirements.MemoryRequest = types.StringValue(*resp.ResourceRequirements.MemoryRequest) - } else { - r.ResourceRequirements.MemoryRequest = types.StringNull() - } - } - if resp.ScheduleData == nil { - r.ScheduleData = nil - } else { - r.ScheduleData = &ConnectionScheduleData{} - if resp.ScheduleData.BasicSchedule == nil { - r.ScheduleData.BasicSchedule = nil - } else { - r.ScheduleData.BasicSchedule = &BasicSchedule{} - r.ScheduleData.BasicSchedule.TimeUnit = types.StringValue(string(resp.ScheduleData.BasicSchedule.TimeUnit)) - r.ScheduleData.BasicSchedule.Units = types.Int64Value(resp.ScheduleData.BasicSchedule.Units) - } - if resp.ScheduleData.Cron == nil { - r.ScheduleData.Cron = nil - } else { - r.ScheduleData.Cron = &Cron{} - r.ScheduleData.Cron.CronExpression = types.StringValue(resp.ScheduleData.Cron.CronExpression) - r.ScheduleData.Cron.CronTimeZone = types.StringValue(resp.ScheduleData.Cron.CronTimeZone) - } - } - if resp.ScheduleType != nil { - r.ScheduleType = types.StringValue(string(*resp.ScheduleType)) - } else { - r.ScheduleType = types.StringNull() - } - if resp.SourceCatalogID != nil { - r.SourceCatalogID = types.StringValue(*resp.SourceCatalogID) - } else { - r.SourceCatalogID = types.StringNull() - } - r.SourceID = types.StringValue(resp.SourceID) - r.Status = types.StringValue(string(resp.Status)) - if r.SyncCatalog == nil { - r.SyncCatalog = &AirbyteCatalog{} - } - if len(r.SyncCatalog.Streams) > len(resp.SyncCatalog.Streams) { - r.SyncCatalog.Streams = r.SyncCatalog.Streams[:len(resp.SyncCatalog.Streams)] - } - for streamsCount, streamsItem := range resp.SyncCatalog.Streams { - var streams1 AirbyteStreamAndConfiguration - if streamsItem.Config == nil { - streams1.Config = nil - } else { - streams1.Config = &AirbyteStreamConfiguration{} - if streamsItem.Config.AliasName != nil { - streams1.Config.AliasName = types.StringValue(*streamsItem.Config.AliasName) - } else { - streams1.Config.AliasName = types.StringNull() - } - streams1.Config.CursorField = nil - for _, v := range streamsItem.Config.CursorField { - streams1.Config.CursorField = append(streams1.Config.CursorField, types.StringValue(v)) - } - streams1.Config.DestinationSyncMode = types.StringValue(string(streamsItem.Config.DestinationSyncMode)) - if streamsItem.Config.FieldSelectionEnabled != nil { - streams1.Config.FieldSelectionEnabled = types.BoolValue(*streamsItem.Config.FieldSelectionEnabled) - } else { - streams1.Config.FieldSelectionEnabled = types.BoolNull() - } - streams1.Config.PrimaryKey = nil - for _, primaryKeyItem := range streamsItem.Config.PrimaryKey { - var primaryKey1 []types.String - primaryKey1 = nil - for _, v := range primaryKeyItem { - primaryKey1 = append(primaryKey1, types.StringValue(v)) - } - streams1.Config.PrimaryKey = append(streams1.Config.PrimaryKey, primaryKey1) - } - if streamsItem.Config.Selected != nil { - streams1.Config.Selected = types.BoolValue(*streamsItem.Config.Selected) - } else { - streams1.Config.Selected = types.BoolNull() - } - if len(streams1.Config.SelectedFields) > len(streamsItem.Config.SelectedFields) { - streams1.Config.SelectedFields = streams1.Config.SelectedFields[:len(streamsItem.Config.SelectedFields)] - } - for selectedFieldsCount, selectedFieldsItem := range streamsItem.Config.SelectedFields { - var selectedFields1 SelectedFieldInfo - selectedFields1.FieldPath = nil - for _, v := range selectedFieldsItem.FieldPath { - selectedFields1.FieldPath = append(selectedFields1.FieldPath, types.StringValue(v)) - } - if selectedFieldsCount+1 > len(streams1.Config.SelectedFields) { - streams1.Config.SelectedFields = append(streams1.Config.SelectedFields, selectedFields1) - } else { - streams1.Config.SelectedFields[selectedFieldsCount].FieldPath = selectedFields1.FieldPath - } - } - if streamsItem.Config.Suggested != nil { - streams1.Config.Suggested = types.BoolValue(*streamsItem.Config.Suggested) - } else { - streams1.Config.Suggested = types.BoolNull() - } - streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) - } - if streamsItem.Stream == nil { - streams1.Stream = nil - } else { - streams1.Stream = &AirbyteStream{} - streams1.Stream.DefaultCursorField = nil - for _, v := range streamsItem.Stream.DefaultCursorField { - streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) - } - if streams1.Stream.JSONSchema == nil && len(streamsItem.Stream.JSONSchema) > 0 { - streams1.Stream.JSONSchema = make(map[string]types.String) - for key, value := range streamsItem.Stream.JSONSchema { - result, _ := json.Marshal(value) - streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) - } - } - streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) - if streamsItem.Stream.Namespace != nil { - streams1.Stream.Namespace = types.StringValue(*streamsItem.Stream.Namespace) - } else { - streams1.Stream.Namespace = types.StringNull() - } - if streamsItem.Stream.SourceDefinedCursor != nil { - streams1.Stream.SourceDefinedCursor = types.BoolValue(*streamsItem.Stream.SourceDefinedCursor) - } else { - streams1.Stream.SourceDefinedCursor = types.BoolNull() - } - streams1.Stream.SourceDefinedPrimaryKey = nil - for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { - var sourceDefinedPrimaryKey1 []types.String - sourceDefinedPrimaryKey1 = nil - for _, v := range sourceDefinedPrimaryKeyItem { - sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) - } - streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) - } - streams1.Stream.SupportedSyncModes = nil - for _, v := range streamsItem.Stream.SupportedSyncModes { - streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) - } - } - if streamsCount+1 > len(r.SyncCatalog.Streams) { - r.SyncCatalog.Streams = append(r.SyncCatalog.Streams, streams1) - } else { - r.SyncCatalog.Streams[streamsCount].Config = streams1.Config - r.SyncCatalog.Streams[streamsCount].Stream = streams1.Stream - } - } - if resp.WorkspaceID != nil { - r.WorkspaceID = types.StringValue(*resp.WorkspaceID) - } else { - r.WorkspaceID = types.StringNull() - } -} - -func (r *ConnectionResourceModel) RefreshFromCreateResponse(resp *shared.ConnectionRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *ConnectionResourceModel) RefreshFromUpdateResponse(resp *shared.ConnectionRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/destination_data_source.go b/internal/provider/destination_data_source.go index d1a9a4f..ac1b3f5 100644 --- a/internal/provider/destination_data_source.go +++ b/internal/provider/destination_data_source.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -132,7 +131,7 @@ func (r *DestinationDataSource) Read(ctx context.Context, req datasource.ReadReq resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.DestinationRead) + data.RefreshFromSharedDestinationRead(res.DestinationRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/destination_data_source_sdk.go b/internal/provider/destination_data_source_sdk.go index 4772def..ade85cd 100644 --- a/internal/provider/destination_data_source_sdk.go +++ b/internal/provider/destination_data_source_sdk.go @@ -7,15 +7,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *DestinationDataSourceModel) RefreshFromGetResponse(resp *shared.DestinationRead) { +func (r *DestinationDataSourceModel) RefreshFromSharedDestinationRead(resp *shared.DestinationRead) { r.DestinationDefinitionID = types.StringValue(resp.DestinationDefinitionID) r.DestinationID = types.StringValue(resp.DestinationID) r.DestinationName = types.StringValue(resp.DestinationName) - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } + r.Icon = types.StringPointerValue(resp.Icon) r.Name = types.StringValue(resp.Name) r.WorkspaceID = types.StringValue(resp.WorkspaceID) } diff --git a/internal/provider/destination_resource.go b/internal/provider/destination_resource.go index a4916ac..03e0e29 100644 --- a/internal/provider/destination_resource.go +++ b/internal/provider/destination_resource.go @@ -4,9 +4,10 @@ package provider import ( "context" + "encoding/json" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/aballiet/terraform-provider-airbyte/internal/validators" "github.com/hashicorp/terraform-plugin-framework/path" @@ -53,18 +54,19 @@ func (r *DestinationResource) Schema(ctx context.Context, req resource.SchemaReq Attributes: map[string]schema.Attribute{ "connection_configuration": schema.StringAttribute{ - Required: true, - MarkdownDescription: `Parsed as JSON.` + "\n" + - `The values required to configure the destination. The schema for this must match the schema return by destination_definition_specifications/get for the destinationDefinition.`, + Required: true, + Description: `The values required to configure the destination. The schema for this must match the schema return by destination_definition_specifications/get for the destinationDefinition. Parsed as JSON.`, Validators: []validator.String{ validators.IsValidJSON(), }, }, "destination_definition_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "destination_id": schema.StringAttribute{ Computed: true, @@ -80,9 +82,11 @@ func (r *DestinationResource) Schema(ctx context.Context, req resource.SchemaReq }, "workspace_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, }, } @@ -110,14 +114,14 @@ func (r *DestinationResource) Configure(ctx context.Context, req resource.Config func (r *DestinationResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *DestinationResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -126,7 +130,17 @@ func (r *DestinationResource) Create(ctx context.Context, req resource.CreateReq return } - request := *data.ToCreateSDKType() + workspaceID := data.WorkspaceID.ValueString() + name := data.Name.ValueString() + destinationDefinitionID := data.DestinationDefinitionID.ValueString() + var connectionConfiguration interface{} + _ = json.Unmarshal([]byte(data.ConnectionConfiguration.ValueString()), &connectionConfiguration) + request := shared.DestinationCreate{ + WorkspaceID: workspaceID, + Name: name, + DestinationDefinitionID: destinationDefinitionID, + ConnectionConfiguration: connectionConfiguration, + } res, err := r.client.Destination.CreateDestination(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -147,7 +161,34 @@ func (r *DestinationResource) Create(ctx context.Context, req resource.CreateReq resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.DestinationRead) + data.RefreshFromSharedDestinationRead(res.DestinationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + destinationID := data.DestinationID.ValueString() + request1 := shared.DestinationIDRequestBody{ + DestinationID: destinationID, + } + res1, err := r.client.Destination.GetDestination(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.DestinationRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedDestinationRead(res1.DestinationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -195,7 +236,7 @@ func (r *DestinationResource) Read(ctx context.Context, req resource.ReadRequest resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.DestinationRead) + data.RefreshFromSharedDestinationRead(res.DestinationRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -203,12 +244,27 @@ func (r *DestinationResource) Read(ctx context.Context, req resource.ReadRequest func (r *DestinationResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *DestinationResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + destinationID := data.DestinationID.ValueString() + var connectionConfiguration interface{} + _ = json.Unmarshal([]byte(data.ConnectionConfiguration.ValueString()), &connectionConfiguration) + name := data.Name.ValueString() + request := shared.DestinationUpdate{ + DestinationID: destinationID, + ConnectionConfiguration: connectionConfiguration, + Name: name, + } res, err := r.client.Destination.UpdateDestination(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -229,7 +285,34 @@ func (r *DestinationResource) Update(ctx context.Context, req resource.UpdateReq resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.DestinationRead) + data.RefreshFromSharedDestinationRead(res.DestinationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + destinationId1 := data.DestinationID.ValueString() + request1 := shared.DestinationIDRequestBody{ + DestinationID: destinationId1, + } + res1, err := r.client.Destination.GetDestination(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.DestinationRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedDestinationRead(res1.DestinationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/destination_resource_sdk.go b/internal/provider/destination_resource_sdk.go index 95ef486..f896be8 100644 --- a/internal/provider/destination_resource_sdk.go +++ b/internal/provider/destination_resource_sdk.go @@ -3,66 +3,15 @@ package provider import ( - "encoding/json" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *DestinationResourceModel) ToCreateSDKType() *shared.DestinationCreate { - workspaceID := r.WorkspaceID.ValueString() - name := r.Name.ValueString() - destinationDefinitionID := r.DestinationDefinitionID.ValueString() - var connectionConfiguration interface{} - _ = json.Unmarshal([]byte(r.ConnectionConfiguration.ValueString()), &connectionConfiguration) - out := shared.DestinationCreate{ - WorkspaceID: workspaceID, - Name: name, - DestinationDefinitionID: destinationDefinitionID, - ConnectionConfiguration: connectionConfiguration, - } - return &out -} - -func (r *DestinationResourceModel) ToGetSDKType() *shared.DestinationCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *DestinationResourceModel) ToUpdateSDKType() *shared.DestinationUpdate { - destinationID := r.DestinationID.ValueString() - var connectionConfiguration interface{} - _ = json.Unmarshal([]byte(r.ConnectionConfiguration.ValueString()), &connectionConfiguration) - name := r.Name.ValueString() - out := shared.DestinationUpdate{ - DestinationID: destinationID, - ConnectionConfiguration: connectionConfiguration, - Name: name, - } - return &out -} - -func (r *DestinationResourceModel) ToDeleteSDKType() *shared.DestinationCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *DestinationResourceModel) RefreshFromGetResponse(resp *shared.DestinationRead) { +func (r *DestinationResourceModel) RefreshFromSharedDestinationRead(resp *shared.DestinationRead) { r.DestinationDefinitionID = types.StringValue(resp.DestinationDefinitionID) r.DestinationID = types.StringValue(resp.DestinationID) r.DestinationName = types.StringValue(resp.DestinationName) - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } + r.Icon = types.StringPointerValue(resp.Icon) r.Name = types.StringValue(resp.Name) r.WorkspaceID = types.StringValue(resp.WorkspaceID) } - -func (r *DestinationResourceModel) RefreshFromCreateResponse(resp *shared.DestinationRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *DestinationResourceModel) RefreshFromUpdateResponse(resp *shared.DestinationRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/destinationdefinition_data_source.go b/internal/provider/destinationdefinition_data_source.go index 9281546..342ad7b 100644 --- a/internal/provider/destinationdefinition_data_source.go +++ b/internal/provider/destinationdefinition_data_source.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -57,9 +56,8 @@ func (r *DestinationDefinitionDataSource) Schema(ctx context.Context, req dataso Attributes: map[string]schema.Attribute{ "custom": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `Whether the connector is custom or not`, + Computed: true, + Description: `Whether the connector is custom or not`, }, "destination_definition_id": schema.StringAttribute{ Required: true, @@ -82,10 +80,9 @@ func (r *DestinationDefinitionDataSource) Schema(ctx context.Context, req dataso "normalization_config": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "supported": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `whether the destination definition supports normalization.`, + "normalization_integration_type": schema.StringAttribute{ + Computed: true, + Description: `a field indicating the type of integration dialect to use for normalization.`, }, "normalization_repository": schema.StringAttribute{ Computed: true, @@ -95,9 +92,9 @@ func (r *DestinationDefinitionDataSource) Schema(ctx context.Context, req dataso Computed: true, Description: `a field indicating the tag of the docker repository to be used for normalization.`, }, - "normalization_integration_type": schema.StringAttribute{ + "supported": schema.BoolAttribute{ Computed: true, - Description: `a field indicating the type of integration dialect to use for normalization.`, + Description: `whether the destination definition supports normalization.`, }, }, Description: `describes a normalization config for destination definition version`, @@ -120,18 +117,18 @@ func (r *DestinationDefinitionDataSource) Schema(ctx context.Context, req dataso "default": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - Computed: true, - }, "cpu_limit": schema.StringAttribute{ Computed: true, }, - "memory_request": schema.StringAttribute{ + "cpu_request": schema.StringAttribute{ Computed: true, }, "memory_limit": schema.StringAttribute{ Computed: true, }, + "memory_request": schema.StringAttribute{ + Computed: true, + }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, @@ -140,25 +137,24 @@ func (r *DestinationDefinitionDataSource) Schema(ctx context.Context, req dataso NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "job_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, + Computed: true, + Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, }, "resource_requirements": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - Computed: true, - }, "cpu_limit": schema.StringAttribute{ Computed: true, }, - "memory_request": schema.StringAttribute{ + "cpu_request": schema.StringAttribute{ Computed: true, }, "memory_limit": schema.StringAttribute{ Computed: true, }, + "memory_request": schema.StringAttribute{ + Computed: true, + }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, @@ -242,7 +238,7 @@ func (r *DestinationDefinitionDataSource) Read(ctx context.Context, req datasour resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.DestinationDefinitionRead) + data.RefreshFromSharedDestinationDefinitionRead(res.DestinationDefinitionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/destinationdefinition_data_source_sdk.go b/internal/provider/destinationdefinition_data_source_sdk.go index 610d6b5..f7a9fbf 100644 --- a/internal/provider/destinationdefinition_data_source_sdk.go +++ b/internal/provider/destinationdefinition_data_source_sdk.go @@ -5,49 +5,22 @@ package provider import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" + "time" ) -func (r *DestinationDefinitionDataSourceModel) RefreshFromGetResponse(resp *shared.DestinationDefinitionRead) { - if resp.Custom != nil { - r.Custom = types.BoolValue(*resp.Custom) - } else { - r.Custom = types.BoolNull() - } +func (r *DestinationDefinitionDataSourceModel) RefreshFromSharedDestinationDefinitionRead(resp *shared.DestinationDefinitionRead) { + r.Custom = types.BoolPointerValue(resp.Custom) r.DestinationDefinitionID = types.StringValue(resp.DestinationDefinitionID) r.DockerImageTag = types.StringValue(resp.DockerImageTag) r.DockerRepository = types.StringValue(resp.DockerRepository) r.DocumentationURL = types.StringValue(resp.DocumentationURL) - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } + r.Icon = types.StringPointerValue(resp.Icon) r.Name = types.StringValue(resp.Name) - if resp.NormalizationConfig.Supported != nil { - r.NormalizationConfig.Supported = types.BoolValue(*resp.NormalizationConfig.Supported) - } else { - r.NormalizationConfig.Supported = types.BoolNull() - } - if resp.NormalizationConfig.NormalizationRepository != nil { - r.NormalizationConfig.NormalizationRepository = types.StringValue(*resp.NormalizationConfig.NormalizationRepository) - } else { - r.NormalizationConfig.NormalizationRepository = types.StringNull() - } - if resp.NormalizationConfig.NormalizationTag != nil { - r.NormalizationConfig.NormalizationTag = types.StringValue(*resp.NormalizationConfig.NormalizationTag) - } else { - r.NormalizationConfig.NormalizationTag = types.StringNull() - } - if resp.NormalizationConfig.NormalizationIntegrationType != nil { - r.NormalizationConfig.NormalizationIntegrationType = types.StringValue(*resp.NormalizationConfig.NormalizationIntegrationType) - } else { - r.NormalizationConfig.NormalizationIntegrationType = types.StringNull() - } - if resp.ProtocolVersion != nil { - r.ProtocolVersion = types.StringValue(*resp.ProtocolVersion) - } else { - r.ProtocolVersion = types.StringNull() - } + r.NormalizationConfig.NormalizationIntegrationType = types.StringPointerValue(resp.NormalizationConfig.NormalizationIntegrationType) + r.NormalizationConfig.NormalizationRepository = types.StringPointerValue(resp.NormalizationConfig.NormalizationRepository) + r.NormalizationConfig.NormalizationTag = types.StringPointerValue(resp.NormalizationConfig.NormalizationTag) + r.NormalizationConfig.Supported = types.BoolPointerValue(resp.NormalizationConfig.Supported) + r.ProtocolVersion = types.StringPointerValue(resp.ProtocolVersion) if resp.ReleaseDate != nil { r.ReleaseDate = types.StringValue(resp.ReleaseDate.String()) } else { @@ -66,26 +39,10 @@ func (r *DestinationDefinitionDataSourceModel) RefreshFromGetResponse(resp *shar r.ResourceRequirements.Default = nil } else { r.ResourceRequirements.Default = &ResourceRequirements{} - if resp.ResourceRequirements.Default.CPURequest != nil { - r.ResourceRequirements.Default.CPURequest = types.StringValue(*resp.ResourceRequirements.Default.CPURequest) - } else { - r.ResourceRequirements.Default.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.Default.CPULimit != nil { - r.ResourceRequirements.Default.CPULimit = types.StringValue(*resp.ResourceRequirements.Default.CPULimit) - } else { - r.ResourceRequirements.Default.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryRequest != nil { - r.ResourceRequirements.Default.MemoryRequest = types.StringValue(*resp.ResourceRequirements.Default.MemoryRequest) - } else { - r.ResourceRequirements.Default.MemoryRequest = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryLimit != nil { - r.ResourceRequirements.Default.MemoryLimit = types.StringValue(*resp.ResourceRequirements.Default.MemoryLimit) - } else { - r.ResourceRequirements.Default.MemoryLimit = types.StringNull() - } + r.ResourceRequirements.Default.CPULimit = types.StringPointerValue(resp.ResourceRequirements.Default.CPULimit) + r.ResourceRequirements.Default.CPURequest = types.StringPointerValue(resp.ResourceRequirements.Default.CPURequest) + r.ResourceRequirements.Default.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryLimit) + r.ResourceRequirements.Default.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryRequest) } if len(r.ResourceRequirements.JobSpecific) > len(resp.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = r.ResourceRequirements.JobSpecific[:len(resp.ResourceRequirements.JobSpecific)] @@ -93,26 +50,10 @@ func (r *DestinationDefinitionDataSourceModel) RefreshFromGetResponse(resp *shar for jobSpecificCount, jobSpecificItem := range resp.ResourceRequirements.JobSpecific { var jobSpecific1 JobTypeResourceLimit jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType)) - if jobSpecificItem.ResourceRequirements.CPURequest != nil { - jobSpecific1.ResourceRequirements.CPURequest = types.StringValue(*jobSpecificItem.ResourceRequirements.CPURequest) - } else { - jobSpecific1.ResourceRequirements.CPURequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.CPULimit != nil { - jobSpecific1.ResourceRequirements.CPULimit = types.StringValue(*jobSpecificItem.ResourceRequirements.CPULimit) - } else { - jobSpecific1.ResourceRequirements.CPULimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryRequest != nil { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryRequest) - } else { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryLimit != nil { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryLimit) - } else { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringNull() - } + jobSpecific1.ResourceRequirements.CPULimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPULimit) + jobSpecific1.ResourceRequirements.CPURequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPURequest) + jobSpecific1.ResourceRequirements.MemoryLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryLimit) + jobSpecific1.ResourceRequirements.MemoryRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryRequest) if jobSpecificCount+1 > len(r.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = append(r.ResourceRequirements.JobSpecific, jobSpecific1) } else { diff --git a/internal/provider/destinationdefinition_resource.go b/internal/provider/destinationdefinition_resource.go index db5f916..5a25940 100644 --- a/internal/provider/destinationdefinition_resource.go +++ b/internal/provider/destinationdefinition_resource.go @@ -5,16 +5,14 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/aballiet/terraform-provider-airbyte/internal/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -37,13 +35,17 @@ type DestinationDefinitionResource struct { // DestinationDefinitionResourceModel describes the resource data model. type DestinationDefinitionResourceModel struct { + CPULimit types.String `tfsdk:"cpu_limit"` + CPURequest types.String `tfsdk:"cpu_request"` Custom types.Bool `tfsdk:"custom"` - DestinationDefinition DestinationDefinitionCreate `tfsdk:"destination_definition"` DestinationDefinitionID types.String `tfsdk:"destination_definition_id"` DockerImageTag types.String `tfsdk:"docker_image_tag"` DockerRepository types.String `tfsdk:"docker_repository"` DocumentationURL types.String `tfsdk:"documentation_url"` Icon types.String `tfsdk:"icon"` + JobType types.String `tfsdk:"job_type"` + MemoryLimit types.String `tfsdk:"memory_limit"` + MemoryRequest types.String `tfsdk:"memory_request"` Name types.String `tfsdk:"name"` NormalizationConfig NormalizationDestinationDefinitionConfig `tfsdk:"normalization_config"` ProtocolVersion types.String `tfsdk:"protocol_version"` @@ -66,170 +68,75 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource MarkdownDescription: "DestinationDefinition Resource", Attributes: map[string]schema.Attribute{ - "custom": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `Whether the connector is custom or not`, + "cpu_limit": schema.StringAttribute{ + Optional: true, }, - "destination_definition": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Required: true, - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "docker_repository": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "docker_image_tag": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "documentation_url": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "icon": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "resource_requirements": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "default": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "cpu_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - }, - Description: `optional resource requirements to run workers (blank for unbounded allocations)`, - }, - "job_specific": schema.ListNestedAttribute{ - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "job_type": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, - Validators: []validator.String{ - stringvalidator.OneOf( - "get_spec", - "check_connection", - "discover_schema", - "sync", - "reset_connection", - "connection_updater", - "replicate", - ), - }, - }, - "resource_requirements": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Required: true, - Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "cpu_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - }, - Description: `optional resource requirements to run workers (blank for unbounded allocations)`, - }, - }, - }, - }, - }, - Description: `actor definition specific resource requirements. if default is set, these are the requirements that should be set for ALL jobs run for this actor definition. it is overriden by the job type specific configurations. if not set, the platform will use defaults. these values will be overriden by configuration at the connection level.`, - }, - }, + "cpu_request": schema.StringAttribute{ + Optional: true, + }, + "custom": schema.BoolAttribute{ + Computed: true, + Description: `Whether the connector is custom or not`, }, "destination_definition_id": schema.StringAttribute{ Computed: true, }, "docker_image_tag": schema.StringAttribute{ - Computed: true, + Required: true, }, "docker_repository": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "documentation_url": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "icon": schema.StringAttribute{ Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, + "job_type": schema.StringAttribute{ + Required: true, + Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, + Validators: []validator.String{ + stringvalidator.OneOf( + "get_spec", + "check_connection", + "discover_schema", + "sync", + "reset_connection", + "connection_updater", + "replicate", + ), + }, + }, + "memory_limit": schema.StringAttribute{ + Optional: true, + }, + "memory_request": schema.StringAttribute{ + Optional: true, }, "name": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "normalization_config": schema.SingleNestedAttribute{ Computed: true, @@ -247,9 +154,8 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource Description: `a field indicating the tag of the docker repository to be used for normalization.`, }, "supported": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `whether the destination definition supports normalization.`, + Computed: true, + Description: `whether the destination definition supports normalization.`, }, }, Description: `describes a normalization config for destination definition version`, @@ -303,9 +209,8 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "job_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, + Computed: true, + Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, Validators: []validator.String{ stringvalidator.OneOf( "get_spec", @@ -344,16 +249,17 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource }, "scope_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, - Optional: true, + Optional: true, + Description: `Requires replacement if changed. `, }, "scope_type": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, Optional: true, - Description: `must be one of ["workspace", "organization"]`, + Description: `Requires replacement if changed. ; must be one of ["workspace", "organization"]`, Validators: []validator.String{ stringvalidator.OneOf( "workspace", @@ -378,9 +284,10 @@ func (r *DestinationDefinitionResource) Schema(ctx context.Context, req resource }, "workspace_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, - Optional: true, + Optional: true, + Description: `Requires replacement if changed. `, }, }, } @@ -408,14 +315,14 @@ func (r *DestinationDefinitionResource) Configure(ctx context.Context, req resou func (r *DestinationDefinitionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *DestinationDefinitionResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -424,7 +331,105 @@ func (r *DestinationDefinitionResource) Create(ctx context.Context, req resource return } - request := data.ToCreateSDKType() + var request *shared.CustomDestinationDefinitionCreate + workspaceID := new(string) + if !data.WorkspaceID.IsUnknown() && !data.WorkspaceID.IsNull() { + *workspaceID = data.WorkspaceID.ValueString() + } else { + workspaceID = nil + } + name := data.Name.ValueString() + dockerRepository := data.DockerRepository.ValueString() + dockerImageTag := data.DockerImageTag.ValueString() + documentationURL := data.DocumentationURL.ValueString() + icon := new(string) + if !data.Icon.IsUnknown() && !data.Icon.IsNull() { + *icon = data.Icon.ValueString() + } else { + icon = nil + } + var resourceRequirements *shared.ActorDefinitionResourceRequirements + if data != nil { + var defaultVar *shared.ResourceRequirements + if data != nil { + cpuRequest := new(string) + if !data.CPURequest.IsUnknown() && !data.CPURequest.IsNull() { + *cpuRequest = data.CPURequest.ValueString() + } else { + cpuRequest = nil + } + cpuLimit := new(string) + if !data.CPULimit.IsUnknown() && !data.CPULimit.IsNull() { + *cpuLimit = data.CPULimit.ValueString() + } else { + cpuLimit = nil + } + memoryRequest := new(string) + if !data.MemoryRequest.IsUnknown() && !data.MemoryRequest.IsNull() { + *memoryRequest = data.MemoryRequest.ValueString() + } else { + memoryRequest = nil + } + memoryLimit := new(string) + if !data.MemoryLimit.IsUnknown() && !data.MemoryLimit.IsNull() { + *memoryLimit = data.MemoryLimit.ValueString() + } else { + memoryLimit = nil + } + defaultVar = &shared.ResourceRequirements{ + CPURequest: cpuRequest, + CPULimit: cpuLimit, + MemoryRequest: memoryRequest, + MemoryLimit: memoryLimit, + } + } + var jobType *shared.JobType + var cpuRequest1 *string + var cpuLimit1 *string + var memoryRequest1 *string + var memoryLimit1 *string + resourceRequirements1 := shared.ResourceRequirements{ + CPURequest: cpuRequest1, + CPULimit: cpuLimit1, + MemoryRequest: memoryRequest1, + MemoryLimit: memoryLimit1, + } + jobSpecificSingleton := shared.JobTypeResourceLimit{ + JobType: jobType, + ResourceRequirements: resourceRequirements1, + } + jobSpecific := []shared.JobTypeResourceLimit{jobSpecificSingleton} + resourceRequirements = &shared.ActorDefinitionResourceRequirements{ + Default: defaultVar, + JobSpecific: jobSpecific, + } + } + destinationDefinition := shared.DestinationDefinitionCreate{ + Name: name, + DockerRepository: dockerRepository, + DockerImageTag: dockerImageTag, + DocumentationURL: documentationURL, + Icon: icon, + ResourceRequirements: resourceRequirements, + } + scopeID := new(string) + if !data.ScopeID.IsUnknown() && !data.ScopeID.IsNull() { + *scopeID = data.ScopeID.ValueString() + } else { + scopeID = nil + } + scopeType := new(shared.ScopeType) + if !data.ScopeType.IsUnknown() && !data.ScopeType.IsNull() { + *scopeType = shared.ScopeType(data.ScopeType.ValueString()) + } else { + scopeType = nil + } + request = &shared.CustomDestinationDefinitionCreate{ + WorkspaceID: workspaceID, + DestinationDefinition: destinationDefinition, + ScopeID: scopeID, + ScopeType: scopeType, + } res, err := r.client.DestinationDefinition.CreateCustomDestinationDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -445,7 +450,34 @@ func (r *DestinationDefinitionResource) Create(ctx context.Context, req resource resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.DestinationDefinitionRead) + data.RefreshFromSharedDestinationDefinitionRead(res.DestinationDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + destinationDefinitionID := data.DestinationDefinitionID.ValueString() + request1 := shared.DestinationDefinitionIDRequestBody{ + DestinationDefinitionID: destinationDefinitionID, + } + res1, err := r.client.DestinationDefinition.GetDestinationDefinition(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.DestinationDefinitionRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedDestinationDefinitionRead(res1.DestinationDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -493,7 +525,7 @@ func (r *DestinationDefinitionResource) Read(ctx context.Context, req resource.R resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.DestinationDefinitionRead) + data.RefreshFromSharedDestinationDefinitionRead(res.DestinationDefinitionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -501,12 +533,86 @@ func (r *DestinationDefinitionResource) Read(ctx context.Context, req resource.R func (r *DestinationDefinitionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *DestinationDefinitionResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + destinationDefinitionID := data.DestinationDefinitionID.ValueString() + dockerImageTag := new(string) + if !data.DockerImageTag.IsUnknown() && !data.DockerImageTag.IsNull() { + *dockerImageTag = data.DockerImageTag.ValueString() + } else { + dockerImageTag = nil + } + var resourceRequirements *shared.ActorDefinitionResourceRequirements + if data != nil { + var defaultVar *shared.ResourceRequirements + if data != nil { + cpuRequest := new(string) + if !data.CPURequest.IsUnknown() && !data.CPURequest.IsNull() { + *cpuRequest = data.CPURequest.ValueString() + } else { + cpuRequest = nil + } + cpuLimit := new(string) + if !data.CPULimit.IsUnknown() && !data.CPULimit.IsNull() { + *cpuLimit = data.CPULimit.ValueString() + } else { + cpuLimit = nil + } + memoryRequest := new(string) + if !data.MemoryRequest.IsUnknown() && !data.MemoryRequest.IsNull() { + *memoryRequest = data.MemoryRequest.ValueString() + } else { + memoryRequest = nil + } + memoryLimit := new(string) + if !data.MemoryLimit.IsUnknown() && !data.MemoryLimit.IsNull() { + *memoryLimit = data.MemoryLimit.ValueString() + } else { + memoryLimit = nil + } + defaultVar = &shared.ResourceRequirements{ + CPURequest: cpuRequest, + CPULimit: cpuLimit, + MemoryRequest: memoryRequest, + MemoryLimit: memoryLimit, + } + } + var jobType *shared.JobType + var cpuRequest1 *string + var cpuLimit1 *string + var memoryRequest1 *string + var memoryLimit1 *string + resourceRequirements1 := shared.ResourceRequirements{ + CPURequest: cpuRequest1, + CPULimit: cpuLimit1, + MemoryRequest: memoryRequest1, + MemoryLimit: memoryLimit1, + } + jobSpecificSingleton := shared.JobTypeResourceLimit{ + JobType: jobType, + ResourceRequirements: resourceRequirements1, + } + jobSpecific := []shared.JobTypeResourceLimit{jobSpecificSingleton} + resourceRequirements = &shared.ActorDefinitionResourceRequirements{ + Default: defaultVar, + JobSpecific: jobSpecific, + } + } + request := shared.DestinationDefinitionUpdate{ + DestinationDefinitionID: destinationDefinitionID, + DockerImageTag: dockerImageTag, + ResourceRequirements: resourceRequirements, + } res, err := r.client.DestinationDefinition.UpdateDestinationDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -527,7 +633,34 @@ func (r *DestinationDefinitionResource) Update(ctx context.Context, req resource resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.DestinationDefinitionRead) + data.RefreshFromSharedDestinationDefinitionRead(res.DestinationDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + destinationDefinitionId1 := data.DestinationDefinitionID.ValueString() + request1 := shared.DestinationDefinitionIDRequestBody{ + DestinationDefinitionID: destinationDefinitionId1, + } + res1, err := r.client.DestinationDefinition.GetDestinationDefinition(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.DestinationDefinitionRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedDestinationDefinitionRead(res1.DestinationDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/destinationdefinition_resource_sdk.go b/internal/provider/destinationdefinition_resource_sdk.go index 1af8b3d..7bb406a 100644 --- a/internal/provider/destinationdefinition_resource_sdk.go +++ b/internal/provider/destinationdefinition_resource_sdk.go @@ -5,277 +5,22 @@ package provider import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" + "time" ) -func (r *DestinationDefinitionResourceModel) ToCreateSDKType() *shared.CustomDestinationDefinitionCreate { - workspaceID := new(string) - if !r.WorkspaceID.IsUnknown() && !r.WorkspaceID.IsNull() { - *workspaceID = r.WorkspaceID.ValueString() - } else { - workspaceID = nil - } - name := r.DestinationDefinition.Name.ValueString() - dockerRepository := r.DestinationDefinition.DockerRepository.ValueString() - dockerImageTag := r.DestinationDefinition.DockerImageTag.ValueString() - documentationURL := r.DestinationDefinition.DocumentationURL.ValueString() - icon := new(string) - if !r.DestinationDefinition.Icon.IsUnknown() && !r.DestinationDefinition.Icon.IsNull() { - *icon = r.DestinationDefinition.Icon.ValueString() - } else { - icon = nil - } - var resourceRequirements *shared.ActorDefinitionResourceRequirements - if r.DestinationDefinition.ResourceRequirements != nil { - var defaultVar *shared.ResourceRequirements - if r.DestinationDefinition.ResourceRequirements.Default != nil { - cpuRequest := new(string) - if !r.DestinationDefinition.ResourceRequirements.Default.CPURequest.IsUnknown() && !r.DestinationDefinition.ResourceRequirements.Default.CPURequest.IsNull() { - *cpuRequest = r.DestinationDefinition.ResourceRequirements.Default.CPURequest.ValueString() - } else { - cpuRequest = nil - } - cpuLimit := new(string) - if !r.DestinationDefinition.ResourceRequirements.Default.CPULimit.IsUnknown() && !r.DestinationDefinition.ResourceRequirements.Default.CPULimit.IsNull() { - *cpuLimit = r.DestinationDefinition.ResourceRequirements.Default.CPULimit.ValueString() - } else { - cpuLimit = nil - } - memoryRequest := new(string) - if !r.DestinationDefinition.ResourceRequirements.Default.MemoryRequest.IsUnknown() && !r.DestinationDefinition.ResourceRequirements.Default.MemoryRequest.IsNull() { - *memoryRequest = r.DestinationDefinition.ResourceRequirements.Default.MemoryRequest.ValueString() - } else { - memoryRequest = nil - } - memoryLimit := new(string) - if !r.DestinationDefinition.ResourceRequirements.Default.MemoryLimit.IsUnknown() && !r.DestinationDefinition.ResourceRequirements.Default.MemoryLimit.IsNull() { - *memoryLimit = r.DestinationDefinition.ResourceRequirements.Default.MemoryLimit.ValueString() - } else { - memoryLimit = nil - } - defaultVar = &shared.ResourceRequirements{ - CPURequest: cpuRequest, - CPULimit: cpuLimit, - MemoryRequest: memoryRequest, - MemoryLimit: memoryLimit, - } - } - var jobSpecific []shared.JobTypeResourceLimit = nil - for _, jobSpecificItem := range r.DestinationDefinition.ResourceRequirements.JobSpecific { - jobType := shared.JobType(jobSpecificItem.JobType.ValueString()) - cpuRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPURequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPURequest.IsNull() { - *cpuRequest1 = jobSpecificItem.ResourceRequirements.CPURequest.ValueString() - } else { - cpuRequest1 = nil - } - cpuLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPULimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPULimit.IsNull() { - *cpuLimit1 = jobSpecificItem.ResourceRequirements.CPULimit.ValueString() - } else { - cpuLimit1 = nil - } - memoryRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryRequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryRequest.IsNull() { - *memoryRequest1 = jobSpecificItem.ResourceRequirements.MemoryRequest.ValueString() - } else { - memoryRequest1 = nil - } - memoryLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryLimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryLimit.IsNull() { - *memoryLimit1 = jobSpecificItem.ResourceRequirements.MemoryLimit.ValueString() - } else { - memoryLimit1 = nil - } - resourceRequirements1 := shared.ResourceRequirements{ - CPURequest: cpuRequest1, - CPULimit: cpuLimit1, - MemoryRequest: memoryRequest1, - MemoryLimit: memoryLimit1, - } - jobSpecific = append(jobSpecific, shared.JobTypeResourceLimit{ - JobType: jobType, - ResourceRequirements: resourceRequirements1, - }) - } - resourceRequirements = &shared.ActorDefinitionResourceRequirements{ - Default: defaultVar, - JobSpecific: jobSpecific, - } - } - destinationDefinition := shared.DestinationDefinitionCreate{ - Name: name, - DockerRepository: dockerRepository, - DockerImageTag: dockerImageTag, - DocumentationURL: documentationURL, - Icon: icon, - ResourceRequirements: resourceRequirements, - } - scopeID := new(string) - if !r.ScopeID.IsUnknown() && !r.ScopeID.IsNull() { - *scopeID = r.ScopeID.ValueString() - } else { - scopeID = nil - } - scopeType := new(shared.ScopeType) - if !r.ScopeType.IsUnknown() && !r.ScopeType.IsNull() { - *scopeType = shared.ScopeType(r.ScopeType.ValueString()) - } else { - scopeType = nil - } - out := shared.CustomDestinationDefinitionCreate{ - WorkspaceID: workspaceID, - DestinationDefinition: destinationDefinition, - ScopeID: scopeID, - ScopeType: scopeType, - } - return &out -} - -func (r *DestinationDefinitionResourceModel) ToGetSDKType() *shared.CustomDestinationDefinitionCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *DestinationDefinitionResourceModel) ToUpdateSDKType() *shared.DestinationDefinitionUpdate { - destinationDefinitionID := r.DestinationDefinitionID.ValueString() - dockerImageTag := new(string) - if !r.DockerImageTag.IsUnknown() && !r.DockerImageTag.IsNull() { - *dockerImageTag = r.DockerImageTag.ValueString() - } else { - dockerImageTag = nil - } - var resourceRequirements *shared.ActorDefinitionResourceRequirements - if r.ResourceRequirements != nil { - var defaultVar *shared.ResourceRequirements - if r.ResourceRequirements.Default != nil { - cpuRequest := new(string) - if !r.ResourceRequirements.Default.CPURequest.IsUnknown() && !r.ResourceRequirements.Default.CPURequest.IsNull() { - *cpuRequest = r.ResourceRequirements.Default.CPURequest.ValueString() - } else { - cpuRequest = nil - } - cpuLimit := new(string) - if !r.ResourceRequirements.Default.CPULimit.IsUnknown() && !r.ResourceRequirements.Default.CPULimit.IsNull() { - *cpuLimit = r.ResourceRequirements.Default.CPULimit.ValueString() - } else { - cpuLimit = nil - } - memoryRequest := new(string) - if !r.ResourceRequirements.Default.MemoryRequest.IsUnknown() && !r.ResourceRequirements.Default.MemoryRequest.IsNull() { - *memoryRequest = r.ResourceRequirements.Default.MemoryRequest.ValueString() - } else { - memoryRequest = nil - } - memoryLimit := new(string) - if !r.ResourceRequirements.Default.MemoryLimit.IsUnknown() && !r.ResourceRequirements.Default.MemoryLimit.IsNull() { - *memoryLimit = r.ResourceRequirements.Default.MemoryLimit.ValueString() - } else { - memoryLimit = nil - } - defaultVar = &shared.ResourceRequirements{ - CPURequest: cpuRequest, - CPULimit: cpuLimit, - MemoryRequest: memoryRequest, - MemoryLimit: memoryLimit, - } - } - var jobSpecific []shared.JobTypeResourceLimit = nil - for _, jobSpecificItem := range r.ResourceRequirements.JobSpecific { - jobType := shared.JobType(jobSpecificItem.JobType.ValueString()) - cpuRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPURequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPURequest.IsNull() { - *cpuRequest1 = jobSpecificItem.ResourceRequirements.CPURequest.ValueString() - } else { - cpuRequest1 = nil - } - cpuLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPULimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPULimit.IsNull() { - *cpuLimit1 = jobSpecificItem.ResourceRequirements.CPULimit.ValueString() - } else { - cpuLimit1 = nil - } - memoryRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryRequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryRequest.IsNull() { - *memoryRequest1 = jobSpecificItem.ResourceRequirements.MemoryRequest.ValueString() - } else { - memoryRequest1 = nil - } - memoryLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryLimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryLimit.IsNull() { - *memoryLimit1 = jobSpecificItem.ResourceRequirements.MemoryLimit.ValueString() - } else { - memoryLimit1 = nil - } - resourceRequirements1 := shared.ResourceRequirements{ - CPURequest: cpuRequest1, - CPULimit: cpuLimit1, - MemoryRequest: memoryRequest1, - MemoryLimit: memoryLimit1, - } - jobSpecific = append(jobSpecific, shared.JobTypeResourceLimit{ - JobType: jobType, - ResourceRequirements: resourceRequirements1, - }) - } - resourceRequirements = &shared.ActorDefinitionResourceRequirements{ - Default: defaultVar, - JobSpecific: jobSpecific, - } - } - out := shared.DestinationDefinitionUpdate{ - DestinationDefinitionID: destinationDefinitionID, - DockerImageTag: dockerImageTag, - ResourceRequirements: resourceRequirements, - } - return &out -} - -func (r *DestinationDefinitionResourceModel) ToDeleteSDKType() *shared.CustomDestinationDefinitionCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *DestinationDefinitionResourceModel) RefreshFromGetResponse(resp *shared.DestinationDefinitionRead) { - if resp.Custom != nil { - r.Custom = types.BoolValue(*resp.Custom) - } else { - r.Custom = types.BoolNull() - } +func (r *DestinationDefinitionResourceModel) RefreshFromSharedDestinationDefinitionRead(resp *shared.DestinationDefinitionRead) { + r.Custom = types.BoolPointerValue(resp.Custom) r.DestinationDefinitionID = types.StringValue(resp.DestinationDefinitionID) r.DockerImageTag = types.StringValue(resp.DockerImageTag) r.DockerRepository = types.StringValue(resp.DockerRepository) r.DocumentationURL = types.StringValue(resp.DocumentationURL) - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } + r.Icon = types.StringPointerValue(resp.Icon) r.Name = types.StringValue(resp.Name) - if resp.NormalizationConfig.NormalizationIntegrationType != nil { - r.NormalizationConfig.NormalizationIntegrationType = types.StringValue(*resp.NormalizationConfig.NormalizationIntegrationType) - } else { - r.NormalizationConfig.NormalizationIntegrationType = types.StringNull() - } - if resp.NormalizationConfig.NormalizationRepository != nil { - r.NormalizationConfig.NormalizationRepository = types.StringValue(*resp.NormalizationConfig.NormalizationRepository) - } else { - r.NormalizationConfig.NormalizationRepository = types.StringNull() - } - if resp.NormalizationConfig.NormalizationTag != nil { - r.NormalizationConfig.NormalizationTag = types.StringValue(*resp.NormalizationConfig.NormalizationTag) - } else { - r.NormalizationConfig.NormalizationTag = types.StringNull() - } - if resp.NormalizationConfig.Supported != nil { - r.NormalizationConfig.Supported = types.BoolValue(*resp.NormalizationConfig.Supported) - } else { - r.NormalizationConfig.Supported = types.BoolNull() - } - if resp.ProtocolVersion != nil { - r.ProtocolVersion = types.StringValue(*resp.ProtocolVersion) - } else { - r.ProtocolVersion = types.StringNull() - } + r.NormalizationConfig.NormalizationIntegrationType = types.StringPointerValue(resp.NormalizationConfig.NormalizationIntegrationType) + r.NormalizationConfig.NormalizationRepository = types.StringPointerValue(resp.NormalizationConfig.NormalizationRepository) + r.NormalizationConfig.NormalizationTag = types.StringPointerValue(resp.NormalizationConfig.NormalizationTag) + r.NormalizationConfig.Supported = types.BoolPointerValue(resp.NormalizationConfig.Supported) + r.ProtocolVersion = types.StringPointerValue(resp.ProtocolVersion) if resp.ReleaseDate != nil { r.ReleaseDate = types.StringValue(resp.ReleaseDate.String()) } else { @@ -294,26 +39,10 @@ func (r *DestinationDefinitionResourceModel) RefreshFromGetResponse(resp *shared r.ResourceRequirements.Default = nil } else { r.ResourceRequirements.Default = &ResourceRequirements{} - if resp.ResourceRequirements.Default.CPULimit != nil { - r.ResourceRequirements.Default.CPULimit = types.StringValue(*resp.ResourceRequirements.Default.CPULimit) - } else { - r.ResourceRequirements.Default.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.Default.CPURequest != nil { - r.ResourceRequirements.Default.CPURequest = types.StringValue(*resp.ResourceRequirements.Default.CPURequest) - } else { - r.ResourceRequirements.Default.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryLimit != nil { - r.ResourceRequirements.Default.MemoryLimit = types.StringValue(*resp.ResourceRequirements.Default.MemoryLimit) - } else { - r.ResourceRequirements.Default.MemoryLimit = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryRequest != nil { - r.ResourceRequirements.Default.MemoryRequest = types.StringValue(*resp.ResourceRequirements.Default.MemoryRequest) - } else { - r.ResourceRequirements.Default.MemoryRequest = types.StringNull() - } + r.ResourceRequirements.Default.CPULimit = types.StringPointerValue(resp.ResourceRequirements.Default.CPULimit) + r.ResourceRequirements.Default.CPURequest = types.StringPointerValue(resp.ResourceRequirements.Default.CPURequest) + r.ResourceRequirements.Default.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryLimit) + r.ResourceRequirements.Default.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryRequest) } if len(r.ResourceRequirements.JobSpecific) > len(resp.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = r.ResourceRequirements.JobSpecific[:len(resp.ResourceRequirements.JobSpecific)] @@ -321,26 +50,10 @@ func (r *DestinationDefinitionResourceModel) RefreshFromGetResponse(resp *shared for jobSpecificCount, jobSpecificItem := range resp.ResourceRequirements.JobSpecific { var jobSpecific1 JobTypeResourceLimit jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType)) - if jobSpecificItem.ResourceRequirements.CPULimit != nil { - jobSpecific1.ResourceRequirements.CPULimit = types.StringValue(*jobSpecificItem.ResourceRequirements.CPULimit) - } else { - jobSpecific1.ResourceRequirements.CPULimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.CPURequest != nil { - jobSpecific1.ResourceRequirements.CPURequest = types.StringValue(*jobSpecificItem.ResourceRequirements.CPURequest) - } else { - jobSpecific1.ResourceRequirements.CPURequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryLimit != nil { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryLimit) - } else { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryRequest != nil { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryRequest) - } else { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringNull() - } + jobSpecific1.ResourceRequirements.CPULimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPULimit) + jobSpecific1.ResourceRequirements.CPURequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPURequest) + jobSpecific1.ResourceRequirements.MemoryLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryLimit) + jobSpecific1.ResourceRequirements.MemoryRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryRequest) if jobSpecificCount+1 > len(r.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = append(r.ResourceRequirements.JobSpecific, jobSpecific1) } else { @@ -356,11 +69,3 @@ func (r *DestinationDefinitionResourceModel) RefreshFromGetResponse(resp *shared } r.SupportsDbt = types.BoolValue(resp.SupportsDbt) } - -func (r *DestinationDefinitionResourceModel) RefreshFromCreateResponse(resp *shared.DestinationDefinitionRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *DestinationDefinitionResourceModel) RefreshFromUpdateResponse(resp *shared.DestinationDefinitionRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/operation_data_source.go b/internal/provider/operation_data_source.go index 0985554..6a861a4 100644 --- a/internal/provider/operation_data_source.go +++ b/internal/provider/operation_data_source.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -55,47 +54,39 @@ func (r *OperationDataSource) Schema(ctx context.Context, req datasource.SchemaR "operator_configuration": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "operator_type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["normalization", "dbt", "webhook"]`, - }, - "normalization": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "option": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["basic"]`, - }, - }, - }, "dbt": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "git_repo_url": schema.StringAttribute{ + "dbt_arguments": schema.StringAttribute{ Computed: true, }, - "git_repo_branch": schema.StringAttribute{ + "docker_image": schema.StringAttribute{ Computed: true, }, - "docker_image": schema.StringAttribute{ + "git_repo_branch": schema.StringAttribute{ Computed: true, }, - "dbt_arguments": schema.StringAttribute{ + "git_repo_url": schema.StringAttribute{ Computed: true, }, }, }, - "webhook": schema.SingleNestedAttribute{ + "normalization": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "webhook_config_id": schema.StringAttribute{ - Computed: true, - Description: `The id of the webhook configs to use from the workspace.`, - }, - "webhook_type": schema.StringAttribute{ + "option": schema.StringAttribute{ Computed: true, - Description: `must be one of ["dbtCloud"]`, + Description: `must be one of ["basic"]`, }, + }, + }, + "operator_type": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["normalization", "dbt", "webhook"]`, + }, + "webhook": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ "dbt_cloud": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ @@ -109,14 +100,22 @@ func (r *OperationDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "execution_url": schema.StringAttribute{ + "execution_body": schema.StringAttribute{ Computed: true, Description: `DEPRECATED. Populate dbtCloud instead.`, }, - "execution_body": schema.StringAttribute{ + "execution_url": schema.StringAttribute{ Computed: true, Description: `DEPRECATED. Populate dbtCloud instead.`, }, + "webhook_config_id": schema.StringAttribute{ + Computed: true, + Description: `The id of the webhook configs to use from the workspace.`, + }, + "webhook_type": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["dbtCloud"]`, + }, }, }, }, @@ -190,7 +189,7 @@ func (r *OperationDataSource) Read(ctx context.Context, req datasource.ReadReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.OperationRead) + data.RefreshFromSharedOperationRead(res.OperationRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/operation_data_source_sdk.go b/internal/provider/operation_data_source_sdk.go index 422361f..5191a44 100644 --- a/internal/provider/operation_data_source_sdk.go +++ b/internal/provider/operation_data_source_sdk.go @@ -7,10 +7,18 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *OperationDataSourceModel) RefreshFromGetResponse(resp *shared.OperationRead) { +func (r *OperationDataSourceModel) RefreshFromSharedOperationRead(resp *shared.OperationRead) { r.Name = types.StringValue(resp.Name) r.OperationID = types.StringValue(resp.OperationID) - r.OperatorConfiguration.OperatorType = types.StringValue(string(resp.OperatorConfiguration.OperatorType)) + if resp.OperatorConfiguration.Dbt == nil { + r.OperatorConfiguration.Dbt = nil + } else { + r.OperatorConfiguration.Dbt = &OperatorDbt{} + r.OperatorConfiguration.Dbt.DbtArguments = types.StringPointerValue(resp.OperatorConfiguration.Dbt.DbtArguments) + r.OperatorConfiguration.Dbt.DockerImage = types.StringPointerValue(resp.OperatorConfiguration.Dbt.DockerImage) + r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringPointerValue(resp.OperatorConfiguration.Dbt.GitRepoBranch) + r.OperatorConfiguration.Dbt.GitRepoURL = types.StringValue(resp.OperatorConfiguration.Dbt.GitRepoURL) + } if resp.OperatorConfiguration.Normalization == nil { r.OperatorConfiguration.Normalization = nil } else { @@ -21,41 +29,11 @@ func (r *OperationDataSourceModel) RefreshFromGetResponse(resp *shared.Operation r.OperatorConfiguration.Normalization.Option = types.StringNull() } } - if resp.OperatorConfiguration.Dbt == nil { - r.OperatorConfiguration.Dbt = nil - } else { - r.OperatorConfiguration.Dbt = &OperatorDbt{} - r.OperatorConfiguration.Dbt.GitRepoURL = types.StringValue(resp.OperatorConfiguration.Dbt.GitRepoURL) - if resp.OperatorConfiguration.Dbt.GitRepoBranch != nil { - r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringValue(*resp.OperatorConfiguration.Dbt.GitRepoBranch) - } else { - r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringNull() - } - if resp.OperatorConfiguration.Dbt.DockerImage != nil { - r.OperatorConfiguration.Dbt.DockerImage = types.StringValue(*resp.OperatorConfiguration.Dbt.DockerImage) - } else { - r.OperatorConfiguration.Dbt.DockerImage = types.StringNull() - } - if resp.OperatorConfiguration.Dbt.DbtArguments != nil { - r.OperatorConfiguration.Dbt.DbtArguments = types.StringValue(*resp.OperatorConfiguration.Dbt.DbtArguments) - } else { - r.OperatorConfiguration.Dbt.DbtArguments = types.StringNull() - } - } + r.OperatorConfiguration.OperatorType = types.StringValue(string(resp.OperatorConfiguration.OperatorType)) if resp.OperatorConfiguration.Webhook == nil { r.OperatorConfiguration.Webhook = nil } else { r.OperatorConfiguration.Webhook = &OperatorWebhook{} - if resp.OperatorConfiguration.Webhook.WebhookConfigID != nil { - r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringValue(*resp.OperatorConfiguration.Webhook.WebhookConfigID) - } else { - r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringNull() - } - if resp.OperatorConfiguration.Webhook.WebhookType != nil { - r.OperatorConfiguration.Webhook.WebhookType = types.StringValue(string(*resp.OperatorConfiguration.Webhook.WebhookType)) - } else { - r.OperatorConfiguration.Webhook.WebhookType = types.StringNull() - } if resp.OperatorConfiguration.Webhook.DbtCloud == nil { r.OperatorConfiguration.Webhook.DbtCloud = nil } else { @@ -63,15 +41,13 @@ func (r *OperationDataSourceModel) RefreshFromGetResponse(resp *shared.Operation r.OperatorConfiguration.Webhook.DbtCloud.AccountID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.AccountID) r.OperatorConfiguration.Webhook.DbtCloud.JobID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.JobID) } - if resp.OperatorConfiguration.Webhook.ExecutionURL != nil { - r.OperatorConfiguration.Webhook.ExecutionURL = types.StringValue(*resp.OperatorConfiguration.Webhook.ExecutionURL) - } else { - r.OperatorConfiguration.Webhook.ExecutionURL = types.StringNull() - } - if resp.OperatorConfiguration.Webhook.ExecutionBody != nil { - r.OperatorConfiguration.Webhook.ExecutionBody = types.StringValue(*resp.OperatorConfiguration.Webhook.ExecutionBody) + r.OperatorConfiguration.Webhook.ExecutionBody = types.StringPointerValue(resp.OperatorConfiguration.Webhook.ExecutionBody) + r.OperatorConfiguration.Webhook.ExecutionURL = types.StringPointerValue(resp.OperatorConfiguration.Webhook.ExecutionURL) + r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringPointerValue(resp.OperatorConfiguration.Webhook.WebhookConfigID) + if resp.OperatorConfiguration.Webhook.WebhookType != nil { + r.OperatorConfiguration.Webhook.WebhookType = types.StringValue(string(*resp.OperatorConfiguration.Webhook.WebhookType)) } else { - r.OperatorConfiguration.Webhook.ExecutionBody = types.StringNull() + r.OperatorConfiguration.Webhook.WebhookType = types.StringNull() } } r.WorkspaceID = types.StringValue(resp.WorkspaceID) diff --git a/internal/provider/operation_resource.go b/internal/provider/operation_resource.go index f2f70eb..3a039df 100644 --- a/internal/provider/operation_resource.go +++ b/internal/provider/operation_resource.go @@ -5,9 +5,11 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" + speakeasy_int64validators "github.com/aballiet/terraform-provider-airbyte/internal/validators/int64validators" + speakeasy_stringvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -75,7 +77,12 @@ func (r *OperationResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, }, "git_repo_url": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -115,12 +122,20 @@ func (r *OperationResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "account_id": schema.Int64Attribute{ - Required: true, - Description: `The account id associated with the job`, + Computed: true, + Optional: true, + Description: `The account id associated with the job. Not Null`, + Validators: []validator.Int64{ + speakeasy_int64validators.NotNull(), + }, }, "job_id": schema.Int64Attribute{ - Required: true, - Description: `The job id associated with the job`, + Computed: true, + Optional: true, + Description: `The job id associated with the job. Not Null`, + Validators: []validator.Int64{ + speakeasy_int64validators.NotNull(), + }, }, }, }, @@ -155,9 +170,11 @@ func (r *OperationResource) Schema(ctx context.Context, req resource.SchemaReque }, "workspace_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, }, } @@ -185,14 +202,14 @@ func (r *OperationResource) Configure(ctx context.Context, req resource.Configur func (r *OperationResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *OperationResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -201,7 +218,7 @@ func (r *OperationResource) Create(ctx context.Context, req resource.CreateReque return } - request := *data.ToCreateSDKType() + request := *data.ToSharedOperationCreate() res, err := r.client.Operation.CreateOperation(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -222,7 +239,8 @@ func (r *OperationResource) Create(ctx context.Context, req resource.CreateReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.OperationRead) + data.RefreshFromSharedOperationRead(res.OperationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -270,7 +288,7 @@ func (r *OperationResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.OperationRead) + data.RefreshFromSharedOperationRead(res.OperationRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -278,12 +296,19 @@ func (r *OperationResource) Read(ctx context.Context, req resource.ReadRequest, func (r *OperationResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *OperationResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + request := *data.ToSharedOperationUpdate() res, err := r.client.Operation.UpdateOperation(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -304,7 +329,8 @@ func (r *OperationResource) Update(ctx context.Context, req resource.UpdateReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.OperationRead) + data.RefreshFromSharedOperationRead(res.OperationRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/operation_resource_sdk.go b/internal/provider/operation_resource_sdk.go index a3c4bc5..0b1ca49 100644 --- a/internal/provider/operation_resource_sdk.go +++ b/internal/provider/operation_resource_sdk.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *OperationResourceModel) ToCreateSDKType() *shared.OperationCreate { +func (r *OperationResourceModel) ToSharedOperationCreate() *shared.OperationCreate { workspaceID := r.WorkspaceID.ValueString() name := r.Name.ValueString() operatorType := shared.OperatorType(r.OperatorConfiguration.OperatorType.ValueString()) @@ -108,12 +108,53 @@ func (r *OperationResourceModel) ToCreateSDKType() *shared.OperationCreate { return &out } -func (r *OperationResourceModel) ToGetSDKType() *shared.OperationCreate { - out := r.ToCreateSDKType() - return out +func (r *OperationResourceModel) RefreshFromSharedOperationRead(resp *shared.OperationRead) { + r.Name = types.StringValue(resp.Name) + r.OperationID = types.StringValue(resp.OperationID) + if resp.OperatorConfiguration.Dbt == nil { + r.OperatorConfiguration.Dbt = nil + } else { + r.OperatorConfiguration.Dbt = &OperatorDbt{} + r.OperatorConfiguration.Dbt.DbtArguments = types.StringPointerValue(resp.OperatorConfiguration.Dbt.DbtArguments) + r.OperatorConfiguration.Dbt.DockerImage = types.StringPointerValue(resp.OperatorConfiguration.Dbt.DockerImage) + r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringPointerValue(resp.OperatorConfiguration.Dbt.GitRepoBranch) + r.OperatorConfiguration.Dbt.GitRepoURL = types.StringValue(resp.OperatorConfiguration.Dbt.GitRepoURL) + } + if resp.OperatorConfiguration.Normalization == nil { + r.OperatorConfiguration.Normalization = nil + } else { + r.OperatorConfiguration.Normalization = &OperatorNormalization{} + if resp.OperatorConfiguration.Normalization.Option != nil { + r.OperatorConfiguration.Normalization.Option = types.StringValue(string(*resp.OperatorConfiguration.Normalization.Option)) + } else { + r.OperatorConfiguration.Normalization.Option = types.StringNull() + } + } + r.OperatorConfiguration.OperatorType = types.StringValue(string(resp.OperatorConfiguration.OperatorType)) + if resp.OperatorConfiguration.Webhook == nil { + r.OperatorConfiguration.Webhook = nil + } else { + r.OperatorConfiguration.Webhook = &OperatorWebhook{} + if resp.OperatorConfiguration.Webhook.DbtCloud == nil { + r.OperatorConfiguration.Webhook.DbtCloud = nil + } else { + r.OperatorConfiguration.Webhook.DbtCloud = &DbtCloud{} + r.OperatorConfiguration.Webhook.DbtCloud.AccountID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.AccountID) + r.OperatorConfiguration.Webhook.DbtCloud.JobID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.JobID) + } + r.OperatorConfiguration.Webhook.ExecutionBody = types.StringPointerValue(resp.OperatorConfiguration.Webhook.ExecutionBody) + r.OperatorConfiguration.Webhook.ExecutionURL = types.StringPointerValue(resp.OperatorConfiguration.Webhook.ExecutionURL) + r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringPointerValue(resp.OperatorConfiguration.Webhook.WebhookConfigID) + if resp.OperatorConfiguration.Webhook.WebhookType != nil { + r.OperatorConfiguration.Webhook.WebhookType = types.StringValue(string(*resp.OperatorConfiguration.Webhook.WebhookType)) + } else { + r.OperatorConfiguration.Webhook.WebhookType = types.StringNull() + } + } + r.WorkspaceID = types.StringValue(resp.WorkspaceID) } -func (r *OperationResourceModel) ToUpdateSDKType() *shared.OperationUpdate { +func (r *OperationResourceModel) ToSharedOperationUpdate() *shared.OperationUpdate { operationID := r.OperationID.ValueString() name := r.Name.ValueString() operatorType := shared.OperatorType(r.OperatorConfiguration.OperatorType.ValueString()) @@ -213,86 +254,3 @@ func (r *OperationResourceModel) ToUpdateSDKType() *shared.OperationUpdate { } return &out } - -func (r *OperationResourceModel) ToDeleteSDKType() *shared.OperationCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *OperationResourceModel) RefreshFromGetResponse(resp *shared.OperationRead) { - r.Name = types.StringValue(resp.Name) - r.OperationID = types.StringValue(resp.OperationID) - if resp.OperatorConfiguration.Dbt == nil { - r.OperatorConfiguration.Dbt = nil - } else { - r.OperatorConfiguration.Dbt = &OperatorDbt{} - if resp.OperatorConfiguration.Dbt.DbtArguments != nil { - r.OperatorConfiguration.Dbt.DbtArguments = types.StringValue(*resp.OperatorConfiguration.Dbt.DbtArguments) - } else { - r.OperatorConfiguration.Dbt.DbtArguments = types.StringNull() - } - if resp.OperatorConfiguration.Dbt.DockerImage != nil { - r.OperatorConfiguration.Dbt.DockerImage = types.StringValue(*resp.OperatorConfiguration.Dbt.DockerImage) - } else { - r.OperatorConfiguration.Dbt.DockerImage = types.StringNull() - } - if resp.OperatorConfiguration.Dbt.GitRepoBranch != nil { - r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringValue(*resp.OperatorConfiguration.Dbt.GitRepoBranch) - } else { - r.OperatorConfiguration.Dbt.GitRepoBranch = types.StringNull() - } - r.OperatorConfiguration.Dbt.GitRepoURL = types.StringValue(resp.OperatorConfiguration.Dbt.GitRepoURL) - } - if resp.OperatorConfiguration.Normalization == nil { - r.OperatorConfiguration.Normalization = nil - } else { - r.OperatorConfiguration.Normalization = &OperatorNormalization{} - if resp.OperatorConfiguration.Normalization.Option != nil { - r.OperatorConfiguration.Normalization.Option = types.StringValue(string(*resp.OperatorConfiguration.Normalization.Option)) - } else { - r.OperatorConfiguration.Normalization.Option = types.StringNull() - } - } - r.OperatorConfiguration.OperatorType = types.StringValue(string(resp.OperatorConfiguration.OperatorType)) - if resp.OperatorConfiguration.Webhook == nil { - r.OperatorConfiguration.Webhook = nil - } else { - r.OperatorConfiguration.Webhook = &OperatorWebhook{} - if resp.OperatorConfiguration.Webhook.DbtCloud == nil { - r.OperatorConfiguration.Webhook.DbtCloud = nil - } else { - r.OperatorConfiguration.Webhook.DbtCloud = &DbtCloud{} - r.OperatorConfiguration.Webhook.DbtCloud.AccountID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.AccountID) - r.OperatorConfiguration.Webhook.DbtCloud.JobID = types.Int64Value(resp.OperatorConfiguration.Webhook.DbtCloud.JobID) - } - if resp.OperatorConfiguration.Webhook.ExecutionBody != nil { - r.OperatorConfiguration.Webhook.ExecutionBody = types.StringValue(*resp.OperatorConfiguration.Webhook.ExecutionBody) - } else { - r.OperatorConfiguration.Webhook.ExecutionBody = types.StringNull() - } - if resp.OperatorConfiguration.Webhook.ExecutionURL != nil { - r.OperatorConfiguration.Webhook.ExecutionURL = types.StringValue(*resp.OperatorConfiguration.Webhook.ExecutionURL) - } else { - r.OperatorConfiguration.Webhook.ExecutionURL = types.StringNull() - } - if resp.OperatorConfiguration.Webhook.WebhookConfigID != nil { - r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringValue(*resp.OperatorConfiguration.Webhook.WebhookConfigID) - } else { - r.OperatorConfiguration.Webhook.WebhookConfigID = types.StringNull() - } - if resp.OperatorConfiguration.Webhook.WebhookType != nil { - r.OperatorConfiguration.Webhook.WebhookType = types.StringValue(string(*resp.OperatorConfiguration.Webhook.WebhookType)) - } else { - r.OperatorConfiguration.Webhook.WebhookType = types.StringNull() - } - } - r.WorkspaceID = types.StringValue(resp.WorkspaceID) -} - -func (r *OperationResourceModel) RefreshFromCreateResponse(resp *shared.OperationRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *OperationResourceModel) RefreshFromUpdateResponse(resp *shared.OperationRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 361f8a1..b7fe26a 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -6,7 +6,6 @@ import ( "context" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" diff --git a/internal/provider/source_data_source.go b/internal/provider/source_data_source.go index 42bb888..3fe14a7 100644 --- a/internal/provider/source_data_source.go +++ b/internal/provider/source_data_source.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -107,7 +106,7 @@ func (r *SourceDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - request := *data.ToGetSDKType() + request := *data.ToSharedSourceIDRequestBody() res, err := r.client.Source.GetSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -128,7 +127,7 @@ func (r *SourceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.SourceRead) + data.RefreshFromSharedSourceRead(res.SourceRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/source_data_source_sdk.go b/internal/provider/source_data_source_sdk.go index 1400994..2b7a8da 100644 --- a/internal/provider/source_data_source_sdk.go +++ b/internal/provider/source_data_source_sdk.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *SourceDataSourceModel) ToGetSDKType() *shared.SourceIDRequestBody { +func (r *SourceDataSourceModel) ToSharedSourceIDRequestBody() *shared.SourceIDRequestBody { sourceID := r.SourceID.ValueString() out := shared.SourceIDRequestBody{ SourceID: sourceID, @@ -15,12 +15,8 @@ func (r *SourceDataSourceModel) ToGetSDKType() *shared.SourceIDRequestBody { return &out } -func (r *SourceDataSourceModel) RefreshFromGetResponse(resp *shared.SourceRead) { - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } +func (r *SourceDataSourceModel) RefreshFromSharedSourceRead(resp *shared.SourceRead) { + r.Icon = types.StringPointerValue(resp.Icon) r.Name = types.StringValue(resp.Name) r.SourceDefinitionID = types.StringValue(resp.SourceDefinitionID) r.SourceID = types.StringValue(resp.SourceID) diff --git a/internal/provider/source_resource.go b/internal/provider/source_resource.go index d587410..be97e49 100644 --- a/internal/provider/source_resource.go +++ b/internal/provider/source_resource.go @@ -5,8 +5,8 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/validators" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -52,9 +52,8 @@ func (r *SourceResource) Schema(ctx context.Context, req resource.SchemaRequest, Attributes: map[string]schema.Attribute{ "connection_configuration": schema.StringAttribute{ - Required: true, - MarkdownDescription: `Parsed as JSON.` + "\n" + - `The values required to configure the source. The schema for this must match the schema return by source_definition_specifications/get for the source.`, + Required: true, + Description: `The values required to configure the source. The schema for this must match the schema return by source_definition_specifications/get for the source. Parsed as JSON.`, Validators: []validator.String{ validators.IsValidJSON(), }, @@ -70,9 +69,11 @@ func (r *SourceResource) Schema(ctx context.Context, req resource.SchemaRequest, }, "source_definition_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "source_id": schema.StringAttribute{ Computed: true, @@ -82,9 +83,11 @@ func (r *SourceResource) Schema(ctx context.Context, req resource.SchemaRequest, }, "workspace_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, }, } @@ -112,14 +115,14 @@ func (r *SourceResource) Configure(ctx context.Context, req resource.ConfigureRe func (r *SourceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *SourceResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -128,7 +131,7 @@ func (r *SourceResource) Create(ctx context.Context, req resource.CreateRequest, return } - request := *data.ToCreateSDKType() + request := *data.ToSharedSourceCreate() res, err := r.client.Source.CreateSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -149,7 +152,31 @@ func (r *SourceResource) Create(ctx context.Context, req resource.CreateRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.SourceRead) + data.RefreshFromSharedSourceRead(res.SourceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + request1 := *data.ToSharedSourceIDRequestBody() + res1, err := r.client.Source.GetSource(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.SourceRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedSourceRead(res1.SourceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -173,7 +200,7 @@ func (r *SourceResource) Read(ctx context.Context, req resource.ReadRequest, res return } - request := *data.ToGetSDKType() + request := *data.ToSharedSourceIDRequestBody() res, err := r.client.Source.GetSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -194,7 +221,7 @@ func (r *SourceResource) Read(ctx context.Context, req resource.ReadRequest, res resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.SourceRead) + data.RefreshFromSharedSourceRead(res.SourceRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -202,12 +229,19 @@ func (r *SourceResource) Read(ctx context.Context, req resource.ReadRequest, res func (r *SourceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *SourceResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + request := *data.ToSharedSourceUpdate() res, err := r.client.Source.UpdateSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -228,7 +262,31 @@ func (r *SourceResource) Update(ctx context.Context, req resource.UpdateRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.SourceRead) + data.RefreshFromSharedSourceRead(res.SourceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + request1 := *data.ToSharedSourceIDRequestBody() + res1, err := r.client.Source.GetSource(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.SourceRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedSourceRead(res1.SourceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -252,7 +310,7 @@ func (r *SourceResource) Delete(ctx context.Context, req resource.DeleteRequest, return } - request := *data.ToDeleteSDKType() + request := *data.ToSharedSourceIDRequestBody() res, err := r.client.Source.DeleteSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) diff --git a/internal/provider/source_resource_sdk.go b/internal/provider/source_resource_sdk.go index f5c2add..dba149e 100644 --- a/internal/provider/source_resource_sdk.go +++ b/internal/provider/source_resource_sdk.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *SourceResourceModel) ToCreateSDKType() *shared.SourceCreate { +func (r *SourceResourceModel) ToSharedSourceCreate() *shared.SourceCreate { sourceDefinitionID := r.SourceDefinitionID.ValueString() var connectionConfiguration interface{} _ = json.Unmarshal([]byte(r.ConnectionConfiguration.ValueString()), &connectionConfiguration) @@ -30,7 +30,16 @@ func (r *SourceResourceModel) ToCreateSDKType() *shared.SourceCreate { return &out } -func (r *SourceResourceModel) ToGetSDKType() *shared.SourceIDRequestBody { +func (r *SourceResourceModel) RefreshFromSharedSourceRead(resp *shared.SourceRead) { + r.Icon = types.StringPointerValue(resp.Icon) + r.Name = types.StringValue(resp.Name) + r.SourceDefinitionID = types.StringValue(resp.SourceDefinitionID) + r.SourceID = types.StringValue(resp.SourceID) + r.SourceName = types.StringValue(resp.SourceName) + r.WorkspaceID = types.StringValue(resp.WorkspaceID) +} + +func (r *SourceResourceModel) ToSharedSourceIDRequestBody() *shared.SourceIDRequestBody { sourceID := r.SourceID.ValueString() out := shared.SourceIDRequestBody{ SourceID: sourceID, @@ -38,7 +47,7 @@ func (r *SourceResourceModel) ToGetSDKType() *shared.SourceIDRequestBody { return &out } -func (r *SourceResourceModel) ToUpdateSDKType() *shared.SourceUpdate { +func (r *SourceResourceModel) ToSharedSourceUpdate() *shared.SourceUpdate { sourceID := r.SourceID.ValueString() var connectionConfiguration interface{} _ = json.Unmarshal([]byte(r.ConnectionConfiguration.ValueString()), &connectionConfiguration) @@ -57,29 +66,3 @@ func (r *SourceResourceModel) ToUpdateSDKType() *shared.SourceUpdate { } return &out } - -func (r *SourceResourceModel) ToDeleteSDKType() *shared.SourceIDRequestBody { - out := r.ToGetSDKType() - return out -} - -func (r *SourceResourceModel) RefreshFromGetResponse(resp *shared.SourceRead) { - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } - r.Name = types.StringValue(resp.Name) - r.SourceDefinitionID = types.StringValue(resp.SourceDefinitionID) - r.SourceID = types.StringValue(resp.SourceID) - r.SourceName = types.StringValue(resp.SourceName) - r.WorkspaceID = types.StringValue(resp.WorkspaceID) -} - -func (r *SourceResourceModel) RefreshFromCreateResponse(resp *shared.SourceRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *SourceResourceModel) RefreshFromUpdateResponse(resp *shared.SourceRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/sourcedefinition_data_source.go b/internal/provider/sourcedefinition_data_source.go index ff0682b..8bd72ee 100644 --- a/internal/provider/sourcedefinition_data_source.go +++ b/internal/provider/sourcedefinition_data_source.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -56,9 +55,8 @@ func (r *SourceDefinitionDataSource) Schema(ctx context.Context, req datasource. Attributes: map[string]schema.Attribute{ "custom": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `Whether the connector is custom or not`, + Computed: true, + Description: `Whether the connector is custom or not`, }, "docker_image_tag": schema.StringAttribute{ Computed: true, @@ -97,18 +95,18 @@ func (r *SourceDefinitionDataSource) Schema(ctx context.Context, req datasource. "default": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - Computed: true, - }, "cpu_limit": schema.StringAttribute{ Computed: true, }, - "memory_request": schema.StringAttribute{ + "cpu_request": schema.StringAttribute{ Computed: true, }, "memory_limit": schema.StringAttribute{ Computed: true, }, + "memory_request": schema.StringAttribute{ + Computed: true, + }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, @@ -117,25 +115,24 @@ func (r *SourceDefinitionDataSource) Schema(ctx context.Context, req datasource. NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "job_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, + Computed: true, + Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, }, "resource_requirements": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - Computed: true, - }, "cpu_limit": schema.StringAttribute{ Computed: true, }, - "memory_request": schema.StringAttribute{ + "cpu_request": schema.StringAttribute{ Computed: true, }, "memory_limit": schema.StringAttribute{ Computed: true, }, + "memory_request": schema.StringAttribute{ + Computed: true, + }, }, Description: `optional resource requirements to run workers (blank for unbounded allocations)`, }, @@ -198,7 +195,7 @@ func (r *SourceDefinitionDataSource) Read(ctx context.Context, req datasource.Re return } - request := *data.ToGetSDKType() + request := *data.ToSharedSourceDefinitionIDRequestBody() res, err := r.client.SourceDefinition.GetSourceDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -219,7 +216,7 @@ func (r *SourceDefinitionDataSource) Read(ctx context.Context, req datasource.Re resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.SourceDefinitionRead) + data.RefreshFromSharedSourceDefinitionRead(res.SourceDefinitionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/sourcedefinition_data_source_sdk.go b/internal/provider/sourcedefinition_data_source_sdk.go index 3a19c56..0cb75ac 100644 --- a/internal/provider/sourcedefinition_data_source_sdk.go +++ b/internal/provider/sourcedefinition_data_source_sdk.go @@ -5,9 +5,10 @@ package provider import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" + "time" ) -func (r *SourceDefinitionDataSourceModel) ToGetSDKType() *shared.SourceDefinitionIDRequestBody { +func (r *SourceDefinitionDataSourceModel) ToSharedSourceDefinitionIDRequestBody() *shared.SourceDefinitionIDRequestBody { sourceDefinitionID := r.SourceDefinitionID.ValueString() out := shared.SourceDefinitionIDRequestBody{ SourceDefinitionID: sourceDefinitionID, @@ -15,35 +16,15 @@ func (r *SourceDefinitionDataSourceModel) ToGetSDKType() *shared.SourceDefinitio return &out } -func (r *SourceDefinitionDataSourceModel) RefreshFromGetResponse(resp *shared.SourceDefinitionRead) { - if resp.Custom != nil { - r.Custom = types.BoolValue(*resp.Custom) - } else { - r.Custom = types.BoolNull() - } +func (r *SourceDefinitionDataSourceModel) RefreshFromSharedSourceDefinitionRead(resp *shared.SourceDefinitionRead) { + r.Custom = types.BoolPointerValue(resp.Custom) r.DockerImageTag = types.StringValue(resp.DockerImageTag) r.DockerRepository = types.StringValue(resp.DockerRepository) - if resp.DocumentationURL != nil { - r.DocumentationURL = types.StringValue(*resp.DocumentationURL) - } else { - r.DocumentationURL = types.StringNull() - } - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } - if resp.MaxSecondsBetweenMessages != nil { - r.MaxSecondsBetweenMessages = types.Int64Value(*resp.MaxSecondsBetweenMessages) - } else { - r.MaxSecondsBetweenMessages = types.Int64Null() - } + r.DocumentationURL = types.StringPointerValue(resp.DocumentationURL) + r.Icon = types.StringPointerValue(resp.Icon) + r.MaxSecondsBetweenMessages = types.Int64PointerValue(resp.MaxSecondsBetweenMessages) r.Name = types.StringValue(resp.Name) - if resp.ProtocolVersion != nil { - r.ProtocolVersion = types.StringValue(*resp.ProtocolVersion) - } else { - r.ProtocolVersion = types.StringNull() - } + r.ProtocolVersion = types.StringPointerValue(resp.ProtocolVersion) if resp.ReleaseDate != nil { r.ReleaseDate = types.StringValue(resp.ReleaseDate.String()) } else { @@ -62,26 +43,10 @@ func (r *SourceDefinitionDataSourceModel) RefreshFromGetResponse(resp *shared.So r.ResourceRequirements.Default = nil } else { r.ResourceRequirements.Default = &ResourceRequirements{} - if resp.ResourceRequirements.Default.CPURequest != nil { - r.ResourceRequirements.Default.CPURequest = types.StringValue(*resp.ResourceRequirements.Default.CPURequest) - } else { - r.ResourceRequirements.Default.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.Default.CPULimit != nil { - r.ResourceRequirements.Default.CPULimit = types.StringValue(*resp.ResourceRequirements.Default.CPULimit) - } else { - r.ResourceRequirements.Default.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryRequest != nil { - r.ResourceRequirements.Default.MemoryRequest = types.StringValue(*resp.ResourceRequirements.Default.MemoryRequest) - } else { - r.ResourceRequirements.Default.MemoryRequest = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryLimit != nil { - r.ResourceRequirements.Default.MemoryLimit = types.StringValue(*resp.ResourceRequirements.Default.MemoryLimit) - } else { - r.ResourceRequirements.Default.MemoryLimit = types.StringNull() - } + r.ResourceRequirements.Default.CPULimit = types.StringPointerValue(resp.ResourceRequirements.Default.CPULimit) + r.ResourceRequirements.Default.CPURequest = types.StringPointerValue(resp.ResourceRequirements.Default.CPURequest) + r.ResourceRequirements.Default.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryLimit) + r.ResourceRequirements.Default.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryRequest) } if len(r.ResourceRequirements.JobSpecific) > len(resp.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = r.ResourceRequirements.JobSpecific[:len(resp.ResourceRequirements.JobSpecific)] @@ -89,26 +54,10 @@ func (r *SourceDefinitionDataSourceModel) RefreshFromGetResponse(resp *shared.So for jobSpecificCount, jobSpecificItem := range resp.ResourceRequirements.JobSpecific { var jobSpecific1 JobTypeResourceLimit jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType)) - if jobSpecificItem.ResourceRequirements.CPURequest != nil { - jobSpecific1.ResourceRequirements.CPURequest = types.StringValue(*jobSpecificItem.ResourceRequirements.CPURequest) - } else { - jobSpecific1.ResourceRequirements.CPURequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.CPULimit != nil { - jobSpecific1.ResourceRequirements.CPULimit = types.StringValue(*jobSpecificItem.ResourceRequirements.CPULimit) - } else { - jobSpecific1.ResourceRequirements.CPULimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryRequest != nil { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryRequest) - } else { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryLimit != nil { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryLimit) - } else { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringNull() - } + jobSpecific1.ResourceRequirements.CPULimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPULimit) + jobSpecific1.ResourceRequirements.CPURequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPURequest) + jobSpecific1.ResourceRequirements.MemoryLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryLimit) + jobSpecific1.ResourceRequirements.MemoryRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryRequest) if jobSpecificCount+1 > len(r.ResourceRequirements.JobSpecific) { r.ResourceRequirements.JobSpecific = append(r.ResourceRequirements.JobSpecific, jobSpecific1) } else { diff --git a/internal/provider/sourcedefinition_resource.go b/internal/provider/sourcedefinition_resource.go index 1b1ff26..c168b26 100644 --- a/internal/provider/sourcedefinition_resource.go +++ b/internal/provider/sourcedefinition_resource.go @@ -5,14 +5,13 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - + "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/aballiet/terraform-provider-airbyte/internal/validators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -35,12 +34,17 @@ type SourceDefinitionResource struct { // SourceDefinitionResourceModel describes the resource data model. type SourceDefinitionResourceModel struct { + CPULimit types.String `tfsdk:"cpu_limit"` + CPURequest types.String `tfsdk:"cpu_request"` Custom types.Bool `tfsdk:"custom"` DockerImageTag types.String `tfsdk:"docker_image_tag"` DockerRepository types.String `tfsdk:"docker_repository"` DocumentationURL types.String `tfsdk:"documentation_url"` Icon types.String `tfsdk:"icon"` + JobType types.String `tfsdk:"job_type"` MaxSecondsBetweenMessages types.Int64 `tfsdk:"max_seconds_between_messages"` + MemoryLimit types.String `tfsdk:"memory_limit"` + MemoryRequest types.String `tfsdk:"memory_request"` Name types.String `tfsdk:"name"` ProtocolVersion types.String `tfsdk:"protocol_version"` ReleaseDate types.String `tfsdk:"release_date"` @@ -48,7 +52,6 @@ type SourceDefinitionResourceModel struct { ResourceRequirements *ActorDefinitionResourceRequirements `tfsdk:"resource_requirements"` ScopeID types.String `tfsdk:"scope_id"` ScopeType types.String `tfsdk:"scope_type"` - SourceDefinition DestinationDefinitionCreate `tfsdk:"source_definition"` SourceDefinitionID types.String `tfsdk:"source_definition_id"` SourceType types.String `tfsdk:"source_type"` SupportLevel types.String `tfsdk:"support_level"` @@ -64,29 +67,95 @@ func (r *SourceDefinitionResource) Schema(ctx context.Context, req resource.Sche MarkdownDescription: "SourceDefinition Resource", Attributes: map[string]schema.Attribute{ + "cpu_limit": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, + "cpu_request": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, "custom": schema.BoolAttribute{ - Computed: true, - MarkdownDescription: `Default: false` + "\n" + - `Whether the connector is custom or not`, + Computed: true, + Description: `Whether the connector is custom or not`, }, "docker_image_tag": schema.StringAttribute{ - Computed: true, + Required: true, }, "docker_repository": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "documentation_url": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "icon": schema.StringAttribute{ Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, + "job_type": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Required: true, + Description: `enum that describes the different types of jobs that the platform runs. Requires replacement if changed. ; must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, + Validators: []validator.String{ + stringvalidator.OneOf( + "get_spec", + "check_connection", + "discover_schema", + "sync", + "reset_connection", + "connection_updater", + "replicate", + ), + }, }, "max_seconds_between_messages": schema.Int64Attribute{ Computed: true, Description: `Number of seconds allowed between 2 airbyte protocol messages. The source will timeout if this delay is reach`, }, + "memory_limit": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, + "memory_request": schema.StringAttribute{ + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + }, + Optional: true, + Description: `Requires replacement if changed. `, + }, "name": schema.StringAttribute{ - Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), + }, + Required: true, + Description: `Requires replacement if changed. `, }, "protocol_version": schema.StringAttribute{ Computed: true, @@ -137,9 +206,8 @@ func (r *SourceDefinitionResource) Schema(ctx context.Context, req resource.Sche NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "job_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, + Computed: true, + Description: `enum that describes the different types of jobs that the platform runs. must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]`, Validators: []validator.String{ stringvalidator.OneOf( "get_spec", @@ -178,16 +246,17 @@ func (r *SourceDefinitionResource) Schema(ctx context.Context, req resource.Sche }, "scope_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, - Optional: true, + Optional: true, + Description: `Requires replacement if changed. `, }, "scope_type": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, Optional: true, - Description: `must be one of ["workspace", "organization"]`, + Description: `Requires replacement if changed. ; must be one of ["workspace", "organization"]`, Validators: []validator.String{ stringvalidator.OneOf( "workspace", @@ -195,148 +264,6 @@ func (r *SourceDefinitionResource) Schema(ctx context.Context, req resource.Sche ), }, }, - "source_definition": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Required: true, - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "docker_repository": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "docker_image_tag": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "documentation_url": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - }, - "icon": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "resource_requirements": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "default": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Optional: true, - Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "cpu_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - }, - Description: `optional resource requirements to run workers (blank for unbounded allocations)`, - }, - "job_specific": schema.ListNestedAttribute{ - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "job_type": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Required: true, - MarkdownDescription: `must be one of ["get_spec", "check_connection", "discover_schema", "sync", "reset_connection", "connection_updater", "replicate"]` + "\n" + - `enum that describes the different types of jobs that the platform runs.`, - Validators: []validator.String{ - stringvalidator.OneOf( - "get_spec", - "check_connection", - "discover_schema", - "sync", - "reset_connection", - "connection_updater", - "replicate", - ), - }, - }, - "resource_requirements": schema.SingleNestedAttribute{ - PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), - }, - Required: true, - Attributes: map[string]schema.Attribute{ - "cpu_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "cpu_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_request": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - "memory_limit": schema.StringAttribute{ - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Optional: true, - }, - }, - Description: `optional resource requirements to run workers (blank for unbounded allocations)`, - }, - }, - }, - }, - }, - Description: `actor definition specific resource requirements. if default is set, these are the requirements that should be set for ALL jobs run for this actor definition. it is overriden by the job type specific configurations. if not set, the platform will use defaults. these values will be overriden by configuration at the connection level.`, - }, - }, - }, "source_definition_id": schema.StringAttribute{ Computed: true, }, @@ -365,9 +292,10 @@ func (r *SourceDefinitionResource) Schema(ctx context.Context, req resource.Sche }, "workspace_id": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, - Optional: true, + Optional: true, + Description: `Requires replacement if changed. `, }, }, } @@ -395,14 +323,14 @@ func (r *SourceDefinitionResource) Configure(ctx context.Context, req resource.C func (r *SourceDefinitionResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *SourceDefinitionResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -411,7 +339,105 @@ func (r *SourceDefinitionResource) Create(ctx context.Context, req resource.Crea return } - request := data.ToCreateSDKType() + var request *shared.CustomSourceDefinitionCreate + workspaceID := new(string) + if !data.WorkspaceID.IsUnknown() && !data.WorkspaceID.IsNull() { + *workspaceID = data.WorkspaceID.ValueString() + } else { + workspaceID = nil + } + scopeID := new(string) + if !data.ScopeID.IsUnknown() && !data.ScopeID.IsNull() { + *scopeID = data.ScopeID.ValueString() + } else { + scopeID = nil + } + scopeType := new(shared.ScopeType) + if !data.ScopeType.IsUnknown() && !data.ScopeType.IsNull() { + *scopeType = shared.ScopeType(data.ScopeType.ValueString()) + } else { + scopeType = nil + } + name := data.Name.ValueString() + dockerRepository := data.DockerRepository.ValueString() + dockerImageTag := data.DockerImageTag.ValueString() + documentationURL := data.DocumentationURL.ValueString() + icon := new(string) + if !data.Icon.IsUnknown() && !data.Icon.IsNull() { + *icon = data.Icon.ValueString() + } else { + icon = nil + } + var resourceRequirements *shared.ActorDefinitionResourceRequirements + if data != nil { + var defaultVar *shared.ResourceRequirements + if data != nil { + cpuRequest := new(string) + if !data.CPURequest.IsUnknown() && !data.CPURequest.IsNull() { + *cpuRequest = data.CPURequest.ValueString() + } else { + cpuRequest = nil + } + cpuLimit := new(string) + if !data.CPULimit.IsUnknown() && !data.CPULimit.IsNull() { + *cpuLimit = data.CPULimit.ValueString() + } else { + cpuLimit = nil + } + memoryRequest := new(string) + if !data.MemoryRequest.IsUnknown() && !data.MemoryRequest.IsNull() { + *memoryRequest = data.MemoryRequest.ValueString() + } else { + memoryRequest = nil + } + memoryLimit := new(string) + if !data.MemoryLimit.IsUnknown() && !data.MemoryLimit.IsNull() { + *memoryLimit = data.MemoryLimit.ValueString() + } else { + memoryLimit = nil + } + defaultVar = &shared.ResourceRequirements{ + CPURequest: cpuRequest, + CPULimit: cpuLimit, + MemoryRequest: memoryRequest, + MemoryLimit: memoryLimit, + } + } + var jobType *shared.JobType + var cpuRequest1 *string + var cpuLimit1 *string + var memoryRequest1 *string + var memoryLimit1 *string + resourceRequirements1 := shared.ResourceRequirements{ + CPURequest: cpuRequest1, + CPULimit: cpuLimit1, + MemoryRequest: memoryRequest1, + MemoryLimit: memoryLimit1, + } + jobSpecificSingleton := shared.JobTypeResourceLimit{ + JobType: jobType, + ResourceRequirements: resourceRequirements1, + } + jobSpecific := []shared.JobTypeResourceLimit{jobSpecificSingleton} + resourceRequirements = &shared.ActorDefinitionResourceRequirements{ + Default: defaultVar, + JobSpecific: jobSpecific, + } + } + sourceDefinition := shared.SourceDefinitionCreate{ + Name: name, + DockerRepository: dockerRepository, + DockerImageTag: dockerImageTag, + DocumentationURL: documentationURL, + Icon: icon, + ResourceRequirements: resourceRequirements, + } + request = &shared.CustomSourceDefinitionCreate{ + WorkspaceID: workspaceID, + ScopeID: scopeID, + ScopeType: scopeType, + SourceDefinition: sourceDefinition, + } res, err := r.client.SourceDefinition.CreateCustomSourceDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -432,7 +458,31 @@ func (r *SourceDefinitionResource) Create(ctx context.Context, req resource.Crea resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.SourceDefinitionRead) + data.RefreshFromSharedSourceDefinitionRead(res.SourceDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + request1 := *data.ToSharedSourceDefinitionIDRequestBody() + res1, err := r.client.SourceDefinition.GetSourceDefinition(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.SourceDefinitionRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedSourceDefinitionRead(res1.SourceDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -456,7 +506,7 @@ func (r *SourceDefinitionResource) Read(ctx context.Context, req resource.ReadRe return } - request := *data.ToGetSDKType() + request := *data.ToSharedSourceDefinitionIDRequestBody() res, err := r.client.SourceDefinition.GetSourceDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -477,7 +527,7 @@ func (r *SourceDefinitionResource) Read(ctx context.Context, req resource.ReadRe resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.SourceDefinitionRead) + data.RefreshFromSharedSourceDefinitionRead(res.SourceDefinitionRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -485,12 +535,19 @@ func (r *SourceDefinitionResource) Read(ctx context.Context, req resource.ReadRe func (r *SourceDefinitionResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *SourceDefinitionResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := data.ToUpdateSDKType() + request := data.ToSharedSourceDefinitionUpdate() res, err := r.client.SourceDefinition.UpdateSourceDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -511,7 +568,8 @@ func (r *SourceDefinitionResource) Update(ctx context.Context, req resource.Upda resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.SourceDefinitionRead) + data.RefreshFromSharedSourceDefinitionRead(res.SourceDefinitionRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -535,7 +593,7 @@ func (r *SourceDefinitionResource) Delete(ctx context.Context, req resource.Dele return } - request := *data.ToDeleteSDKType() + request := *data.ToSharedSourceDefinitionIDRequestBody() res, err := r.client.SourceDefinition.DeleteSourceDefinition(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) diff --git a/internal/provider/sourcedefinition_resource_sdk.go b/internal/provider/sourcedefinition_resource_sdk.go index 1ff88e8..44faa4b 100644 --- a/internal/provider/sourcedefinition_resource_sdk.go +++ b/internal/provider/sourcedefinition_resource_sdk.go @@ -5,133 +5,73 @@ package provider import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" "github.com/hashicorp/terraform-plugin-framework/types" + "time" ) -func (r *SourceDefinitionResourceModel) ToCreateSDKType() *shared.CustomSourceDefinitionCreate { - workspaceID := new(string) - if !r.WorkspaceID.IsUnknown() && !r.WorkspaceID.IsNull() { - *workspaceID = r.WorkspaceID.ValueString() - } else { - workspaceID = nil - } - scopeID := new(string) - if !r.ScopeID.IsUnknown() && !r.ScopeID.IsNull() { - *scopeID = r.ScopeID.ValueString() +func (r *SourceDefinitionResourceModel) RefreshFromSharedSourceDefinitionRead(resp *shared.SourceDefinitionRead) { + r.Custom = types.BoolPointerValue(resp.Custom) + r.DockerImageTag = types.StringValue(resp.DockerImageTag) + r.DockerRepository = types.StringValue(resp.DockerRepository) + r.DocumentationURL = types.StringPointerValue(resp.DocumentationURL) + r.Icon = types.StringPointerValue(resp.Icon) + r.MaxSecondsBetweenMessages = types.Int64PointerValue(resp.MaxSecondsBetweenMessages) + r.Name = types.StringValue(resp.Name) + r.ProtocolVersion = types.StringPointerValue(resp.ProtocolVersion) + if resp.ReleaseDate != nil { + r.ReleaseDate = types.StringValue(resp.ReleaseDate.String()) } else { - scopeID = nil + r.ReleaseDate = types.StringNull() } - scopeType := new(shared.ScopeType) - if !r.ScopeType.IsUnknown() && !r.ScopeType.IsNull() { - *scopeType = shared.ScopeType(r.ScopeType.ValueString()) + if resp.ReleaseStage != nil { + r.ReleaseStage = types.StringValue(string(*resp.ReleaseStage)) } else { - scopeType = nil + r.ReleaseStage = types.StringNull() } - name := r.SourceDefinition.Name.ValueString() - dockerRepository := r.SourceDefinition.DockerRepository.ValueString() - dockerImageTag := r.SourceDefinition.DockerImageTag.ValueString() - documentationURL := r.SourceDefinition.DocumentationURL.ValueString() - icon := new(string) - if !r.SourceDefinition.Icon.IsUnknown() && !r.SourceDefinition.Icon.IsNull() { - *icon = r.SourceDefinition.Icon.ValueString() + if resp.ResourceRequirements == nil { + r.ResourceRequirements = nil } else { - icon = nil - } - var resourceRequirements *shared.ActorDefinitionResourceRequirements - if r.SourceDefinition.ResourceRequirements != nil { - var defaultVar *shared.ResourceRequirements - if r.SourceDefinition.ResourceRequirements.Default != nil { - cpuRequest := new(string) - if !r.SourceDefinition.ResourceRequirements.Default.CPURequest.IsUnknown() && !r.SourceDefinition.ResourceRequirements.Default.CPURequest.IsNull() { - *cpuRequest = r.SourceDefinition.ResourceRequirements.Default.CPURequest.ValueString() - } else { - cpuRequest = nil - } - cpuLimit := new(string) - if !r.SourceDefinition.ResourceRequirements.Default.CPULimit.IsUnknown() && !r.SourceDefinition.ResourceRequirements.Default.CPULimit.IsNull() { - *cpuLimit = r.SourceDefinition.ResourceRequirements.Default.CPULimit.ValueString() - } else { - cpuLimit = nil - } - memoryRequest := new(string) - if !r.SourceDefinition.ResourceRequirements.Default.MemoryRequest.IsUnknown() && !r.SourceDefinition.ResourceRequirements.Default.MemoryRequest.IsNull() { - *memoryRequest = r.SourceDefinition.ResourceRequirements.Default.MemoryRequest.ValueString() - } else { - memoryRequest = nil - } - memoryLimit := new(string) - if !r.SourceDefinition.ResourceRequirements.Default.MemoryLimit.IsUnknown() && !r.SourceDefinition.ResourceRequirements.Default.MemoryLimit.IsNull() { - *memoryLimit = r.SourceDefinition.ResourceRequirements.Default.MemoryLimit.ValueString() - } else { - memoryLimit = nil - } - defaultVar = &shared.ResourceRequirements{ - CPURequest: cpuRequest, - CPULimit: cpuLimit, - MemoryRequest: memoryRequest, - MemoryLimit: memoryLimit, - } + r.ResourceRequirements = &ActorDefinitionResourceRequirements{} + if resp.ResourceRequirements.Default == nil { + r.ResourceRequirements.Default = nil + } else { + r.ResourceRequirements.Default = &ResourceRequirements{} + r.ResourceRequirements.Default.CPULimit = types.StringPointerValue(resp.ResourceRequirements.Default.CPULimit) + r.ResourceRequirements.Default.CPURequest = types.StringPointerValue(resp.ResourceRequirements.Default.CPURequest) + r.ResourceRequirements.Default.MemoryLimit = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryLimit) + r.ResourceRequirements.Default.MemoryRequest = types.StringPointerValue(resp.ResourceRequirements.Default.MemoryRequest) } - var jobSpecific []shared.JobTypeResourceLimit = nil - for _, jobSpecificItem := range r.SourceDefinition.ResourceRequirements.JobSpecific { - jobType := shared.JobType(jobSpecificItem.JobType.ValueString()) - cpuRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPURequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPURequest.IsNull() { - *cpuRequest1 = jobSpecificItem.ResourceRequirements.CPURequest.ValueString() - } else { - cpuRequest1 = nil - } - cpuLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.CPULimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.CPULimit.IsNull() { - *cpuLimit1 = jobSpecificItem.ResourceRequirements.CPULimit.ValueString() - } else { - cpuLimit1 = nil - } - memoryRequest1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryRequest.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryRequest.IsNull() { - *memoryRequest1 = jobSpecificItem.ResourceRequirements.MemoryRequest.ValueString() - } else { - memoryRequest1 = nil - } - memoryLimit1 := new(string) - if !jobSpecificItem.ResourceRequirements.MemoryLimit.IsUnknown() && !jobSpecificItem.ResourceRequirements.MemoryLimit.IsNull() { - *memoryLimit1 = jobSpecificItem.ResourceRequirements.MemoryLimit.ValueString() + if len(r.ResourceRequirements.JobSpecific) > len(resp.ResourceRequirements.JobSpecific) { + r.ResourceRequirements.JobSpecific = r.ResourceRequirements.JobSpecific[:len(resp.ResourceRequirements.JobSpecific)] + } + for jobSpecificCount, jobSpecificItem := range resp.ResourceRequirements.JobSpecific { + var jobSpecific1 JobTypeResourceLimit + jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType)) + jobSpecific1.ResourceRequirements.CPULimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPULimit) + jobSpecific1.ResourceRequirements.CPURequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.CPURequest) + jobSpecific1.ResourceRequirements.MemoryLimit = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryLimit) + jobSpecific1.ResourceRequirements.MemoryRequest = types.StringPointerValue(jobSpecificItem.ResourceRequirements.MemoryRequest) + if jobSpecificCount+1 > len(r.ResourceRequirements.JobSpecific) { + r.ResourceRequirements.JobSpecific = append(r.ResourceRequirements.JobSpecific, jobSpecific1) } else { - memoryLimit1 = nil - } - resourceRequirements1 := shared.ResourceRequirements{ - CPURequest: cpuRequest1, - CPULimit: cpuLimit1, - MemoryRequest: memoryRequest1, - MemoryLimit: memoryLimit1, + r.ResourceRequirements.JobSpecific[jobSpecificCount].JobType = jobSpecific1.JobType + r.ResourceRequirements.JobSpecific[jobSpecificCount].ResourceRequirements = jobSpecific1.ResourceRequirements } - jobSpecific = append(jobSpecific, shared.JobTypeResourceLimit{ - JobType: jobType, - ResourceRequirements: resourceRequirements1, - }) - } - resourceRequirements = &shared.ActorDefinitionResourceRequirements{ - Default: defaultVar, - JobSpecific: jobSpecific, } } - sourceDefinition := shared.SourceDefinitionCreate{ - Name: name, - DockerRepository: dockerRepository, - DockerImageTag: dockerImageTag, - DocumentationURL: documentationURL, - Icon: icon, - ResourceRequirements: resourceRequirements, + r.SourceDefinitionID = types.StringValue(resp.SourceDefinitionID) + if resp.SourceType != nil { + r.SourceType = types.StringValue(string(*resp.SourceType)) + } else { + r.SourceType = types.StringNull() } - out := shared.CustomSourceDefinitionCreate{ - WorkspaceID: workspaceID, - ScopeID: scopeID, - ScopeType: scopeType, - SourceDefinition: sourceDefinition, + if resp.SupportLevel != nil { + r.SupportLevel = types.StringValue(string(*resp.SupportLevel)) + } else { + r.SupportLevel = types.StringNull() } - return &out } -func (r *SourceDefinitionResourceModel) ToGetSDKType() *shared.SourceDefinitionIDRequestBody { +func (r *SourceDefinitionResourceModel) ToSharedSourceDefinitionIDRequestBody() *shared.SourceDefinitionIDRequestBody { sourceDefinitionID := r.SourceDefinitionID.ValueString() out := shared.SourceDefinitionIDRequestBody{ SourceDefinitionID: sourceDefinitionID, @@ -139,7 +79,7 @@ func (r *SourceDefinitionResourceModel) ToGetSDKType() *shared.SourceDefinitionI return &out } -func (r *SourceDefinitionResourceModel) ToUpdateSDKType() *shared.SourceDefinitionUpdate { +func (r *SourceDefinitionResourceModel) ToSharedSourceDefinitionUpdate() *shared.SourceDefinitionUpdate { sourceDefinitionID := r.SourceDefinitionID.ValueString() dockerImageTag := r.DockerImageTag.ValueString() var resourceRequirements *shared.ActorDefinitionResourceRequirements @@ -227,131 +167,3 @@ func (r *SourceDefinitionResourceModel) ToUpdateSDKType() *shared.SourceDefiniti } return &out } - -func (r *SourceDefinitionResourceModel) ToDeleteSDKType() *shared.SourceDefinitionIDRequestBody { - out := r.ToGetSDKType() - return out -} - -func (r *SourceDefinitionResourceModel) RefreshFromGetResponse(resp *shared.SourceDefinitionRead) { - if resp.Custom != nil { - r.Custom = types.BoolValue(*resp.Custom) - } else { - r.Custom = types.BoolNull() - } - r.DockerImageTag = types.StringValue(resp.DockerImageTag) - r.DockerRepository = types.StringValue(resp.DockerRepository) - if resp.DocumentationURL != nil { - r.DocumentationURL = types.StringValue(*resp.DocumentationURL) - } else { - r.DocumentationURL = types.StringNull() - } - if resp.Icon != nil { - r.Icon = types.StringValue(*resp.Icon) - } else { - r.Icon = types.StringNull() - } - if resp.MaxSecondsBetweenMessages != nil { - r.MaxSecondsBetweenMessages = types.Int64Value(*resp.MaxSecondsBetweenMessages) - } else { - r.MaxSecondsBetweenMessages = types.Int64Null() - } - r.Name = types.StringValue(resp.Name) - if resp.ProtocolVersion != nil { - r.ProtocolVersion = types.StringValue(*resp.ProtocolVersion) - } else { - r.ProtocolVersion = types.StringNull() - } - if resp.ReleaseDate != nil { - r.ReleaseDate = types.StringValue(resp.ReleaseDate.String()) - } else { - r.ReleaseDate = types.StringNull() - } - if resp.ReleaseStage != nil { - r.ReleaseStage = types.StringValue(string(*resp.ReleaseStage)) - } else { - r.ReleaseStage = types.StringNull() - } - if resp.ResourceRequirements == nil { - r.ResourceRequirements = nil - } else { - r.ResourceRequirements = &ActorDefinitionResourceRequirements{} - if resp.ResourceRequirements.Default == nil { - r.ResourceRequirements.Default = nil - } else { - r.ResourceRequirements.Default = &ResourceRequirements{} - if resp.ResourceRequirements.Default.CPULimit != nil { - r.ResourceRequirements.Default.CPULimit = types.StringValue(*resp.ResourceRequirements.Default.CPULimit) - } else { - r.ResourceRequirements.Default.CPULimit = types.StringNull() - } - if resp.ResourceRequirements.Default.CPURequest != nil { - r.ResourceRequirements.Default.CPURequest = types.StringValue(*resp.ResourceRequirements.Default.CPURequest) - } else { - r.ResourceRequirements.Default.CPURequest = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryLimit != nil { - r.ResourceRequirements.Default.MemoryLimit = types.StringValue(*resp.ResourceRequirements.Default.MemoryLimit) - } else { - r.ResourceRequirements.Default.MemoryLimit = types.StringNull() - } - if resp.ResourceRequirements.Default.MemoryRequest != nil { - r.ResourceRequirements.Default.MemoryRequest = types.StringValue(*resp.ResourceRequirements.Default.MemoryRequest) - } else { - r.ResourceRequirements.Default.MemoryRequest = types.StringNull() - } - } - if len(r.ResourceRequirements.JobSpecific) > len(resp.ResourceRequirements.JobSpecific) { - r.ResourceRequirements.JobSpecific = r.ResourceRequirements.JobSpecific[:len(resp.ResourceRequirements.JobSpecific)] - } - for jobSpecificCount, jobSpecificItem := range resp.ResourceRequirements.JobSpecific { - var jobSpecific1 JobTypeResourceLimit - jobSpecific1.JobType = types.StringValue(string(jobSpecificItem.JobType)) - if jobSpecificItem.ResourceRequirements.CPULimit != nil { - jobSpecific1.ResourceRequirements.CPULimit = types.StringValue(*jobSpecificItem.ResourceRequirements.CPULimit) - } else { - jobSpecific1.ResourceRequirements.CPULimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.CPURequest != nil { - jobSpecific1.ResourceRequirements.CPURequest = types.StringValue(*jobSpecificItem.ResourceRequirements.CPURequest) - } else { - jobSpecific1.ResourceRequirements.CPURequest = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryLimit != nil { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryLimit) - } else { - jobSpecific1.ResourceRequirements.MemoryLimit = types.StringNull() - } - if jobSpecificItem.ResourceRequirements.MemoryRequest != nil { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringValue(*jobSpecificItem.ResourceRequirements.MemoryRequest) - } else { - jobSpecific1.ResourceRequirements.MemoryRequest = types.StringNull() - } - if jobSpecificCount+1 > len(r.ResourceRequirements.JobSpecific) { - r.ResourceRequirements.JobSpecific = append(r.ResourceRequirements.JobSpecific, jobSpecific1) - } else { - r.ResourceRequirements.JobSpecific[jobSpecificCount].JobType = jobSpecific1.JobType - r.ResourceRequirements.JobSpecific[jobSpecificCount].ResourceRequirements = jobSpecific1.ResourceRequirements - } - } - } - r.SourceDefinitionID = types.StringValue(resp.SourceDefinitionID) - if resp.SourceType != nil { - r.SourceType = types.StringValue(string(*resp.SourceType)) - } else { - r.SourceType = types.StringNull() - } - if resp.SupportLevel != nil { - r.SupportLevel = types.StringValue(string(*resp.SupportLevel)) - } else { - r.SupportLevel = types.StringNull() - } -} - -func (r *SourceDefinitionResourceModel) RefreshFromCreateResponse(resp *shared.SourceDefinitionRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *SourceDefinitionResourceModel) RefreshFromUpdateResponse(resp *shared.SourceDefinitionRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/provider/sourcedefinitionmanifest_resource.go b/internal/provider/sourcedefinitionmanifest_resource.go index 52b449a..70cf5f1 100644 --- a/internal/provider/sourcedefinitionmanifest_resource.go +++ b/internal/provider/sourcedefinitionmanifest_resource.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" @@ -33,16 +32,10 @@ type SourceDefinitionManifestResource struct { // SourceDefinitionManifestResourceModel describes the resource data model. type SourceDefinitionManifestResourceModel struct { - DeclarativeManifest DeclarativeSourceManifest `tfsdk:"declarative_manifest"` - ExceptionClassName types.String `tfsdk:"exception_class_name"` - ExceptionStack []types.String `tfsdk:"exception_stack"` - ID types.String `tfsdk:"id"` - Message types.String `tfsdk:"message"` - RootCauseExceptionClassName types.String `tfsdk:"root_cause_exception_class_name"` - RootCauseExceptionStack []types.String `tfsdk:"root_cause_exception_stack"` - SetAsActiveManifest types.Bool `tfsdk:"set_as_active_manifest"` - SourceDefinitionID types.String `tfsdk:"source_definition_id"` - WorkspaceID types.String `tfsdk:"workspace_id"` + DeclarativeManifest DeclarativeSourceManifest `tfsdk:"declarative_manifest"` + SetAsActiveManifest types.Bool `tfsdk:"set_as_active_manifest"` + SourceDefinitionID types.String `tfsdk:"source_definition_id"` + WorkspaceID types.String `tfsdk:"workspace_id"` } func (r *SourceDefinitionManifestResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { @@ -56,65 +49,49 @@ func (r *SourceDefinitionManifestResource) Schema(ctx context.Context, req resou Attributes: map[string]schema.Attribute{ "declarative_manifest": schema.SingleNestedAttribute{ PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), + objectplanmodifier.RequiresReplaceIfConfigured(), }, Required: true, Attributes: map[string]schema.Attribute{ "description": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "manifest": schema.SingleNestedAttribute{ PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), + objectplanmodifier.RequiresReplaceIfConfigured(), }, Required: true, Attributes: map[string]schema.Attribute{}, - Description: `Low code CDK manifest JSON object`, + Description: `Low code CDK manifest JSON object. Requires replacement if changed. `, }, "spec": schema.SingleNestedAttribute{ PlanModifiers: []planmodifier.Object{ - objectplanmodifier.RequiresReplace(), + objectplanmodifier.RequiresReplaceIfConfigured(), }, Required: true, Attributes: map[string]schema.Attribute{}, - Description: `The specification for what values are required to configure the sourceDefinition.`, + Description: `The specification for what values are required to configure the sourceDefinition. Requires replacement if changed. `, }, "version": schema.Int64Attribute{ PlanModifiers: []planmodifier.Int64{ - int64planmodifier.RequiresReplace(), + int64planmodifier.RequiresReplaceIfConfigured(), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, }, - }, - "exception_class_name": schema.StringAttribute{ - Computed: true, - }, - "exception_stack": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "id": schema.StringAttribute{ - Computed: true, - }, - "message": schema.StringAttribute{ - Computed: true, - }, - "root_cause_exception_class_name": schema.StringAttribute{ - Computed: true, - }, - "root_cause_exception_stack": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, + Description: `Requires replacement if changed. `, }, "set_as_active_manifest": schema.BoolAttribute{ PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplace(), + boolplanmodifier.RequiresReplaceIfConfigured(), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "source_definition_id": schema.StringAttribute{ Required: true, @@ -148,14 +125,14 @@ func (r *SourceDefinitionManifestResource) Configure(ctx context.Context, req re func (r *SourceDefinitionManifestResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *SourceDefinitionManifestResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -164,7 +141,7 @@ func (r *SourceDefinitionManifestResource) Create(ctx context.Context, req resou return } - request := *data.ToCreateSDKType() + request := *data.ToSharedDeclarativeSourceDefinitionCreateManifestRequestBody() res, err := r.client.DeclarativeSourceDefinitions.CreateDeclarativeSourceDefinitionManifest(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -181,11 +158,7 @@ func (r *SourceDefinitionManifestResource) Create(ctx context.Context, req resou resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) return } - if res.NotFoundKnownExceptionInfo == nil { - resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromCreateResponse(res.NotFoundKnownExceptionInfo) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -217,12 +190,19 @@ func (r *SourceDefinitionManifestResource) Read(ctx context.Context, req resourc func (r *SourceDefinitionManifestResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *SourceDefinitionManifestResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + request := *data.ToSharedUpdateActiveManifestRequestBody() res, err := r.client.DeclarativeSourceDefinitions.UpdateDeclarativeManifestVersion(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -239,11 +219,7 @@ func (r *SourceDefinitionManifestResource) Update(ctx context.Context, req resou resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res.StatusCode), debugResponse(res.RawResponse)) return } - if res.NotFoundKnownExceptionInfo == nil { - resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) - return - } - data.RefreshFromUpdateResponse(res.NotFoundKnownExceptionInfo) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/sourcedefinitionmanifest_resource_sdk.go b/internal/provider/sourcedefinitionmanifest_resource_sdk.go index 025483e..e3bab22 100644 --- a/internal/provider/sourcedefinitionmanifest_resource_sdk.go +++ b/internal/provider/sourcedefinitionmanifest_resource_sdk.go @@ -4,10 +4,9 @@ package provider import ( "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *SourceDefinitionManifestResourceModel) ToCreateSDKType() *shared.DeclarativeSourceDefinitionCreateManifestRequestBody { +func (r *SourceDefinitionManifestResourceModel) ToSharedDeclarativeSourceDefinitionCreateManifestRequestBody() *shared.DeclarativeSourceDefinitionCreateManifestRequestBody { workspaceID := r.WorkspaceID.ValueString() sourceDefinitionID := r.SourceDefinitionID.ValueString() setAsActiveManifest := r.SetAsActiveManifest.ValueBool() @@ -30,7 +29,7 @@ func (r *SourceDefinitionManifestResourceModel) ToCreateSDKType() *shared.Declar return &out } -func (r *SourceDefinitionManifestResourceModel) ToUpdateSDKType() *shared.UpdateActiveManifestRequestBody { +func (r *SourceDefinitionManifestResourceModel) ToSharedUpdateActiveManifestRequestBody() *shared.UpdateActiveManifestRequestBody { workspaceID := r.WorkspaceID.ValueString() sourceDefinitionID := r.SourceDefinitionID.ValueString() out := shared.UpdateActiveManifestRequestBody{ @@ -39,34 +38,3 @@ func (r *SourceDefinitionManifestResourceModel) ToUpdateSDKType() *shared.Update } return &out } - -func (r *SourceDefinitionManifestResourceModel) RefreshFromCreateResponse(resp *shared.NotFoundKnownExceptionInfo) { - if resp.ExceptionClassName != nil { - r.ExceptionClassName = types.StringValue(*resp.ExceptionClassName) - } else { - r.ExceptionClassName = types.StringNull() - } - r.ExceptionStack = nil - for _, v := range resp.ExceptionStack { - r.ExceptionStack = append(r.ExceptionStack, types.StringValue(v)) - } - if resp.ID != nil { - r.ID = types.StringValue(*resp.ID) - } else { - r.ID = types.StringNull() - } - r.Message = types.StringValue(resp.Message) - if resp.RootCauseExceptionClassName != nil { - r.RootCauseExceptionClassName = types.StringValue(*resp.RootCauseExceptionClassName) - } else { - r.RootCauseExceptionClassName = types.StringNull() - } - r.RootCauseExceptionStack = nil - for _, v := range resp.RootCauseExceptionStack { - r.RootCauseExceptionStack = append(r.RootCauseExceptionStack, types.StringValue(v)) - } -} - -func (r *SourceDefinitionManifestResourceModel) RefreshFromUpdateResponse(resp *shared.NotFoundKnownExceptionInfo) { - r.RefreshFromCreateResponse(resp) -} diff --git a/internal/provider/sourceschema_data_source.go b/internal/provider/sourceschema_data_source.go index 9535c86..951fc69 100644 --- a/internal/provider/sourceschema_data_source.go +++ b/internal/provider/sourceschema_data_source.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -61,51 +60,12 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "stream": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - Computed: true, - Description: `Stream's name.`, - }, - "json_schema": schema.MapAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Stream schema using Json Schema specs.`, - }, - "supported_sync_modes": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - "source_defined_cursor": schema.BoolAttribute{ - Computed: true, - Description: `If the source defines the cursor field, then any other cursor field inputs will be ignored. If it does not, either the user_provided one is used, or the default one is used as a backup.`, - }, - "default_cursor_field": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `Path to the field that will be used to determine if a record is new or modified since the last sync. If not provided by the source, the end user will have to specify the comparable themselves.`, - }, - "source_defined_primary_key": schema.ListAttribute{ - Computed: true, - ElementType: types.ListType{ - ElemType: types.StringType, - }, - Description: `If the source defines the primary key, paths to the fields that will be used as a primary key. If not provided by the source, the end user will have to specify the primary key themselves.`, - }, - "namespace": schema.StringAttribute{ - Computed: true, - Description: `Optional Source-defined namespace. Airbyte streams from the same sources should have the same namespace. Currently only used by JDBC destinations to determine what schema to write to.`, - }, - }, - Description: `the immutable schema defined by the source`, - }, "config": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "sync_mode": schema.StringAttribute{ + "alias_name": schema.StringAttribute{ Computed: true, - Description: `must be one of ["full_refresh", "incremental"]`, + Description: `Alias name to the stream to be used in the destination`, }, "cursor_field": schema.ListAttribute{ Computed: true, @@ -116,6 +76,10 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, Description: `must be one of ["append", "overwrite", "append_dedup"]`, }, + "field_selection_enabled": schema.BoolAttribute{ + Computed: true, + Description: `Whether field selection should be enabled. If this is true, only the properties in ` + "`" + `selectedFields` + "`" + ` will be included.`, + }, "primary_key": schema.ListAttribute{ Computed: true, ElementType: types.ListType{ @@ -123,22 +87,10 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche }, Description: `Paths to the fields that will be used as primary key. This field is REQUIRED if ` + "`" + `destination_sync_mode` + "`" + ` is ` + "`" + `*_dedup` + "`" + `. Otherwise it is ignored.`, }, - "alias_name": schema.StringAttribute{ - Computed: true, - Description: `Alias name to the stream to be used in the destination`, - }, "selected": schema.BoolAttribute{ Computed: true, Description: `If this is true, the stream is selected with all of its properties. For new connections, this considers if the stream is suggested or not`, }, - "suggested": schema.BoolAttribute{ - Computed: true, - Description: `Does the connector suggest that this stream be enabled by default?`, - }, - "field_selection_enabled": schema.BoolAttribute{ - Computed: true, - Description: `Whether field selection should be enabled. If this is true, only the properties in ` + "`" + `selectedFields` + "`" + ` will be included.`, - }, "selected_fields": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ @@ -151,9 +103,56 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche }, Description: `Paths to the fields that will be included in the configured catalog. This must be set if ` + "`" + `fieldSelectedEnabled` + "`" + ` is set. An empty list indicates that no properties will be included.`, }, + "suggested": schema.BoolAttribute{ + Computed: true, + Description: `Does the connector suggest that this stream be enabled by default?`, + }, + "sync_mode": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["full_refresh", "incremental"]`, + }, }, Description: `the mutable part of the stream to configure the destination`, }, + "stream": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "default_cursor_field": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `Path to the field that will be used to determine if a record is new or modified since the last sync. If not provided by the source, the end user will have to specify the comparable themselves.`, + }, + "json_schema": schema.MapAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `Stream schema using Json Schema specs.`, + }, + "name": schema.StringAttribute{ + Computed: true, + Description: `Stream's name.`, + }, + "namespace": schema.StringAttribute{ + Computed: true, + Description: `Optional Source-defined namespace. Airbyte streams from the same sources should have the same namespace. Currently only used by JDBC destinations to determine what schema to write to.`, + }, + "source_defined_cursor": schema.BoolAttribute{ + Computed: true, + Description: `If the source defines the cursor field, then any other cursor field inputs will be ignored. If it does not, either the user_provided one is used, or the default one is used as a backup.`, + }, + "source_defined_primary_key": schema.ListAttribute{ + Computed: true, + ElementType: types.ListType{ + ElemType: types.StringType, + }, + Description: `If the source defines the primary key, paths to the fields that will be used as a primary key. If not provided by the source, the end user will have to specify the primary key themselves.`, + }, + "supported_sync_modes": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + }, + }, + Description: `the immutable schema defined by the source`, + }, }, }, }, @@ -167,10 +166,6 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "transform_type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["add_stream", "remove_stream", "update_stream"]`, - }, "stream_descriptor": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ @@ -182,22 +177,14 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche }, }, }, + "transform_type": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["add_stream", "remove_stream", "update_stream"]`, + }, "update_stream": schema.ListNestedAttribute{ Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "transform_type": schema.StringAttribute{ - Computed: true, - Description: `must be one of ["add_field", "remove_field", "update_field_schema"]`, - }, - "field_name": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - Description: `A field name is a list of strings that form the path to the field.`, - }, - "breaking": schema.BoolAttribute{ - Computed: true, - }, "add_field": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ @@ -208,6 +195,14 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche }, }, }, + "breaking": schema.BoolAttribute{ + Computed: true, + }, + "field_name": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + Description: `A field name is a list of strings that form the path to the field.`, + }, "remove_field": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ @@ -218,15 +213,19 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche }, }, }, + "transform_type": schema.StringAttribute{ + Computed: true, + Description: `must be one of ["add_field", "remove_field", "update_field_schema"]`, + }, "update_field_schema": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "old_schema": schema.SingleNestedAttribute{ + "new_schema": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{}, Description: `JSONSchema representation of the field`, }, - "new_schema": schema.SingleNestedAttribute{ + "old_schema": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{}, Description: `JSONSchema representation of the field`, @@ -251,9 +250,8 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche Optional: true, }, "connection_status": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["active", "inactive", "deprecated"]` + "\n" + - `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced.`, + Computed: true, + Description: `Active means that data is flowing through the connection. Inactive means it is not. Deprecated means the connection is off and cannot be re-activated. the schema field describes the elements of the schema that will be synced. must be one of ["active", "inactive", "deprecated"]`, }, "disable_cache": schema.BoolAttribute{ Optional: true, @@ -261,16 +259,16 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche "job_info": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Computed: true, + "config_id": schema.StringAttribute{ + Computed: true, + Description: `only present if a config id was provided.`, }, "config_type": schema.StringAttribute{ Computed: true, Description: `must be one of ["check_connection_source", "check_connection_destination", "discover_schema", "get_spec", "sync", "reset_connection"]`, }, - "config_id": schema.StringAttribute{ - Computed: true, - Description: `only present if a config id was provided.`, + "connector_configuration_updated": schema.BoolAttribute{ + Computed: true, }, "created_at": schema.Int64Attribute{ Computed: true, @@ -278,53 +276,50 @@ func (r *SourceSchemaDataSource) Schema(ctx context.Context, req datasource.Sche "ended_at": schema.Int64Attribute{ Computed: true, }, - "succeeded": schema.BoolAttribute{ - Computed: true, - }, - "connector_configuration_updated": schema.BoolAttribute{ - Computed: true, - Description: `Default: false`, - }, - "logs": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{ - "log_lines": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, - }, - }, - }, "failure_reason": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "failure_origin": schema.StringAttribute{ + "external_message": schema.StringAttribute{ Computed: true, - MarkdownDescription: `must be one of ["source", "destination", "replication", "persistence", "normalization", "dbt", "airbyte_platform", "unknown"]` + "\n" + - `Indicates where the error originated. If not set, the origin of error is not well known.`, }, - "failure_type": schema.StringAttribute{ - Computed: true, - MarkdownDescription: `must be one of ["config_error", "system_error", "manual_cancellation", "refresh_schema", "heartbeat_timeout", "destination_timeout"]` + "\n" + - `Categorizes well known errors into types for programmatic handling. If not set, the type of error is not well known.`, + "failure_origin": schema.StringAttribute{ + Computed: true, + Description: `Indicates where the error originated. If not set, the origin of error is not well known. must be one of ["source", "destination", "replication", "persistence", "normalization", "dbt", "airbyte_platform", "unknown"]`, }, - "external_message": schema.StringAttribute{ - Computed: true, + "failure_type": schema.StringAttribute{ + Computed: true, + Description: `Categorizes well known errors into types for programmatic handling. If not set, the type of error is not well known. must be one of ["config_error", "system_error", "manual_cancellation", "refresh_schema", "heartbeat_timeout", "destination_timeout"]`, }, "internal_message": schema.StringAttribute{ Computed: true, }, - "stacktrace": schema.StringAttribute{ - Computed: true, - }, "retryable": schema.BoolAttribute{ Computed: true, Description: `True if it is known that retrying may succeed, e.g. for a transient failure. False if it is known that a retry will not succeed, e.g. for a configuration issue. If not set, retryable status is not well known.`, }, + "stacktrace": schema.StringAttribute{ + Computed: true, + }, "timestamp": schema.Int64Attribute{ Computed: true, }, }, }, + "id": schema.StringAttribute{ + Computed: true, + }, + "logs": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{ + "log_lines": schema.ListAttribute{ + Computed: true, + ElementType: types.StringType, + }, + }, + }, + "succeeded": schema.BoolAttribute{ + Computed: true, + }, }, }, "notify_schema_change": schema.BoolAttribute{ @@ -375,7 +370,7 @@ func (r *SourceSchemaDataSource) Read(ctx context.Context, req datasource.ReadRe return } - request := *data.ToGetSDKType() + request := *data.ToSharedSourceDiscoverSchemaRequestBody() res, err := r.client.Source.DiscoverSchemaForSource(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -396,7 +391,7 @@ func (r *SourceSchemaDataSource) Read(ctx context.Context, req datasource.ReadRe resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.SourceDiscoverSchemaRead) + data.RefreshFromSharedSourceDiscoverSchemaRead(res.SourceDiscoverSchemaRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/sourceschema_data_source_sdk.go b/internal/provider/sourceschema_data_source_sdk.go index 27671d5..304a6a3 100644 --- a/internal/provider/sourceschema_data_source_sdk.go +++ b/internal/provider/sourceschema_data_source_sdk.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *SourceSchemaDataSourceModel) ToGetSDKType() *shared.SourceDiscoverSchemaRequestBody { +func (r *SourceSchemaDataSourceModel) ToSharedSourceDiscoverSchemaRequestBody() *shared.SourceDiscoverSchemaRequestBody { sourceID := r.SourceID.ValueString() connectionID := new(string) if !r.ConnectionID.IsUnknown() && !r.ConnectionID.IsNull() { @@ -37,12 +37,8 @@ func (r *SourceSchemaDataSourceModel) ToGetSDKType() *shared.SourceDiscoverSchem return &out } -func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.SourceDiscoverSchemaRead) { - if resp.BreakingChange != nil { - r.BreakingChange = types.BoolValue(*resp.BreakingChange) - } else { - r.BreakingChange = types.BoolNull() - } +func (r *SourceSchemaDataSourceModel) RefreshFromSharedSourceDiscoverSchemaRead(resp *shared.SourceDiscoverSchemaRead) { + r.BreakingChange = types.BoolPointerValue(resp.BreakingChange) if resp.Catalog == nil { r.Catalog = nil } else { @@ -52,56 +48,17 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source } for streamsCount, streamsItem := range resp.Catalog.Streams { var streams1 AirbyteStreamAndConfiguration - if streamsItem.Stream == nil { - streams1.Stream = nil - } else { - streams1.Stream = &AirbyteStream{} - streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) - if streams1.Stream.JSONSchema == nil && len(streamsItem.Stream.JSONSchema) > 0 { - streams1.Stream.JSONSchema = make(map[string]types.String) - for key, value := range streamsItem.Stream.JSONSchema { - result, _ := json.Marshal(value) - streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) - } - } - streams1.Stream.SupportedSyncModes = nil - for _, v := range streamsItem.Stream.SupportedSyncModes { - streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) - } - if streamsItem.Stream.SourceDefinedCursor != nil { - streams1.Stream.SourceDefinedCursor = types.BoolValue(*streamsItem.Stream.SourceDefinedCursor) - } else { - streams1.Stream.SourceDefinedCursor = types.BoolNull() - } - streams1.Stream.DefaultCursorField = nil - for _, v := range streamsItem.Stream.DefaultCursorField { - streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) - } - streams1.Stream.SourceDefinedPrimaryKey = nil - for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { - var sourceDefinedPrimaryKey1 []types.String - sourceDefinedPrimaryKey1 = nil - for _, v := range sourceDefinedPrimaryKeyItem { - sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) - } - streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) - } - if streamsItem.Stream.Namespace != nil { - streams1.Stream.Namespace = types.StringValue(*streamsItem.Stream.Namespace) - } else { - streams1.Stream.Namespace = types.StringNull() - } - } if streamsItem.Config == nil { streams1.Config = nil } else { streams1.Config = &AirbyteStreamConfiguration{} - streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) + streams1.Config.AliasName = types.StringPointerValue(streamsItem.Config.AliasName) streams1.Config.CursorField = nil for _, v := range streamsItem.Config.CursorField { streams1.Config.CursorField = append(streams1.Config.CursorField, types.StringValue(v)) } streams1.Config.DestinationSyncMode = types.StringValue(string(streamsItem.Config.DestinationSyncMode)) + streams1.Config.FieldSelectionEnabled = types.BoolPointerValue(streamsItem.Config.FieldSelectionEnabled) streams1.Config.PrimaryKey = nil for _, primaryKeyItem := range streamsItem.Config.PrimaryKey { var primaryKey1 []types.String @@ -111,29 +68,7 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source } streams1.Config.PrimaryKey = append(streams1.Config.PrimaryKey, primaryKey1) } - if streamsItem.Config.AliasName != nil { - streams1.Config.AliasName = types.StringValue(*streamsItem.Config.AliasName) - } else { - streams1.Config.AliasName = types.StringNull() - } - if streamsItem.Config.Selected != nil { - streams1.Config.Selected = types.BoolValue(*streamsItem.Config.Selected) - } else { - streams1.Config.Selected = types.BoolNull() - } - if streamsItem.Config.Suggested != nil { - streams1.Config.Suggested = types.BoolValue(*streamsItem.Config.Suggested) - } else { - streams1.Config.Suggested = types.BoolNull() - } - if streamsItem.Config.FieldSelectionEnabled != nil { - streams1.Config.FieldSelectionEnabled = types.BoolValue(*streamsItem.Config.FieldSelectionEnabled) - } else { - streams1.Config.FieldSelectionEnabled = types.BoolNull() - } - if len(streams1.Config.SelectedFields) > len(streamsItem.Config.SelectedFields) { - streams1.Config.SelectedFields = streams1.Config.SelectedFields[:len(streamsItem.Config.SelectedFields)] - } + streams1.Config.Selected = types.BoolPointerValue(streamsItem.Config.Selected) for selectedFieldsCount, selectedFieldsItem := range streamsItem.Config.SelectedFields { var selectedFields1 SelectedFieldInfo selectedFields1.FieldPath = nil @@ -146,12 +81,46 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source streams1.Config.SelectedFields[selectedFieldsCount].FieldPath = selectedFields1.FieldPath } } + streams1.Config.Suggested = types.BoolPointerValue(streamsItem.Config.Suggested) + streams1.Config.SyncMode = types.StringValue(string(streamsItem.Config.SyncMode)) + } + if streamsItem.Stream == nil { + streams1.Stream = nil + } else { + streams1.Stream = &AirbyteStream{} + streams1.Stream.DefaultCursorField = nil + for _, v := range streamsItem.Stream.DefaultCursorField { + streams1.Stream.DefaultCursorField = append(streams1.Stream.DefaultCursorField, types.StringValue(v)) + } + if len(streamsItem.Stream.JSONSchema) > 0 { + streams1.Stream.JSONSchema = make(map[string]types.String) + for key, value := range streamsItem.Stream.JSONSchema { + result, _ := json.Marshal(value) + streams1.Stream.JSONSchema[key] = types.StringValue(string(result)) + } + } + streams1.Stream.Name = types.StringValue(streamsItem.Stream.Name) + streams1.Stream.Namespace = types.StringPointerValue(streamsItem.Stream.Namespace) + streams1.Stream.SourceDefinedCursor = types.BoolPointerValue(streamsItem.Stream.SourceDefinedCursor) + streams1.Stream.SourceDefinedPrimaryKey = nil + for _, sourceDefinedPrimaryKeyItem := range streamsItem.Stream.SourceDefinedPrimaryKey { + var sourceDefinedPrimaryKey1 []types.String + sourceDefinedPrimaryKey1 = nil + for _, v := range sourceDefinedPrimaryKeyItem { + sourceDefinedPrimaryKey1 = append(sourceDefinedPrimaryKey1, types.StringValue(v)) + } + streams1.Stream.SourceDefinedPrimaryKey = append(streams1.Stream.SourceDefinedPrimaryKey, sourceDefinedPrimaryKey1) + } + streams1.Stream.SupportedSyncModes = nil + for _, v := range streamsItem.Stream.SupportedSyncModes { + streams1.Stream.SupportedSyncModes = append(streams1.Stream.SupportedSyncModes, types.StringValue(string(v))) + } } if streamsCount+1 > len(r.Catalog.Streams) { r.Catalog.Streams = append(r.Catalog.Streams, streams1) } else { - r.Catalog.Streams[streamsCount].Stream = streams1.Stream r.Catalog.Streams[streamsCount].Config = streams1.Config + r.Catalog.Streams[streamsCount].Stream = streams1.Stream } } } @@ -164,24 +133,11 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source } for transformsCount, transformsItem := range resp.CatalogDiff.Transforms { var transforms1 StreamTransform - transforms1.TransformType = types.StringValue(string(transformsItem.TransformType)) transforms1.StreamDescriptor.Name = types.StringValue(transformsItem.StreamDescriptor.Name) - if transformsItem.StreamDescriptor.Namespace != nil { - transforms1.StreamDescriptor.Namespace = types.StringValue(*transformsItem.StreamDescriptor.Namespace) - } else { - transforms1.StreamDescriptor.Namespace = types.StringNull() - } - if len(transforms1.UpdateStream) > len(transformsItem.UpdateStream) { - transforms1.UpdateStream = transforms1.UpdateStream[:len(transformsItem.UpdateStream)] - } + transforms1.StreamDescriptor.Namespace = types.StringPointerValue(transformsItem.StreamDescriptor.Namespace) + transforms1.TransformType = types.StringValue(string(transformsItem.TransformType)) for updateStreamCount, updateStreamItem := range transformsItem.UpdateStream { var updateStream1 FieldTransform - updateStream1.TransformType = types.StringValue(string(updateStreamItem.TransformType)) - updateStream1.FieldName = nil - for _, v := range updateStreamItem.FieldName { - updateStream1.FieldName = append(updateStream1.FieldName, types.StringValue(v)) - } - updateStream1.Breaking = types.BoolValue(updateStreamItem.Breaking) if updateStreamItem.AddField == nil { updateStream1.AddField = nil } else { @@ -192,6 +148,11 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source updateStream1.AddField.Schema = &DeclarativeManifest{} } } + updateStream1.Breaking = types.BoolValue(updateStreamItem.Breaking) + updateStream1.FieldName = nil + for _, v := range updateStreamItem.FieldName { + updateStream1.FieldName = append(updateStream1.FieldName, types.StringValue(v)) + } if updateStreamItem.RemoveField == nil { updateStream1.RemoveField = nil } else { @@ -202,6 +163,7 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source updateStream1.RemoveField.Schema = &DeclarativeManifest{} } } + updateStream1.TransformType = types.StringValue(string(updateStreamItem.TransformType)) if updateStreamItem.UpdateFieldSchema == nil { updateStream1.UpdateFieldSchema = nil } else { @@ -210,61 +172,39 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source if updateStreamCount+1 > len(transforms1.UpdateStream) { transforms1.UpdateStream = append(transforms1.UpdateStream, updateStream1) } else { - transforms1.UpdateStream[updateStreamCount].TransformType = updateStream1.TransformType - transforms1.UpdateStream[updateStreamCount].FieldName = updateStream1.FieldName - transforms1.UpdateStream[updateStreamCount].Breaking = updateStream1.Breaking transforms1.UpdateStream[updateStreamCount].AddField = updateStream1.AddField + transforms1.UpdateStream[updateStreamCount].Breaking = updateStream1.Breaking + transforms1.UpdateStream[updateStreamCount].FieldName = updateStream1.FieldName transforms1.UpdateStream[updateStreamCount].RemoveField = updateStream1.RemoveField + transforms1.UpdateStream[updateStreamCount].TransformType = updateStream1.TransformType transforms1.UpdateStream[updateStreamCount].UpdateFieldSchema = updateStream1.UpdateFieldSchema } } if transformsCount+1 > len(r.CatalogDiff.Transforms) { r.CatalogDiff.Transforms = append(r.CatalogDiff.Transforms, transforms1) } else { - r.CatalogDiff.Transforms[transformsCount].TransformType = transforms1.TransformType r.CatalogDiff.Transforms[transformsCount].StreamDescriptor = transforms1.StreamDescriptor + r.CatalogDiff.Transforms[transformsCount].TransformType = transforms1.TransformType r.CatalogDiff.Transforms[transformsCount].UpdateStream = transforms1.UpdateStream } } } - if resp.CatalogID != nil { - r.CatalogID = types.StringValue(*resp.CatalogID) - } else { - r.CatalogID = types.StringNull() - } + r.CatalogID = types.StringPointerValue(resp.CatalogID) if resp.ConnectionStatus != nil { r.ConnectionStatus = types.StringValue(string(*resp.ConnectionStatus)) } else { r.ConnectionStatus = types.StringNull() } - r.JobInfo.ID = types.StringValue(resp.JobInfo.ID) + r.JobInfo.ConfigID = types.StringPointerValue(resp.JobInfo.ConfigID) r.JobInfo.ConfigType = types.StringValue(string(resp.JobInfo.ConfigType)) - if resp.JobInfo.ConfigID != nil { - r.JobInfo.ConfigID = types.StringValue(*resp.JobInfo.ConfigID) - } else { - r.JobInfo.ConfigID = types.StringNull() - } + r.JobInfo.ConnectorConfigurationUpdated = types.BoolPointerValue(resp.JobInfo.ConnectorConfigurationUpdated) r.JobInfo.CreatedAt = types.Int64Value(resp.JobInfo.CreatedAt) r.JobInfo.EndedAt = types.Int64Value(resp.JobInfo.EndedAt) - r.JobInfo.Succeeded = types.BoolValue(resp.JobInfo.Succeeded) - if resp.JobInfo.ConnectorConfigurationUpdated != nil { - r.JobInfo.ConnectorConfigurationUpdated = types.BoolValue(*resp.JobInfo.ConnectorConfigurationUpdated) - } else { - r.JobInfo.ConnectorConfigurationUpdated = types.BoolNull() - } - if resp.JobInfo.Logs == nil { - r.JobInfo.Logs = nil - } else { - r.JobInfo.Logs = &LogRead{} - r.JobInfo.Logs.LogLines = nil - for _, v := range resp.JobInfo.Logs.LogLines { - r.JobInfo.Logs.LogLines = append(r.JobInfo.Logs.LogLines, types.StringValue(v)) - } - } if resp.JobInfo.FailureReason == nil { r.JobInfo.FailureReason = nil } else { r.JobInfo.FailureReason = &FailureReason{} + r.JobInfo.FailureReason.ExternalMessage = types.StringPointerValue(resp.JobInfo.FailureReason.ExternalMessage) if resp.JobInfo.FailureReason.FailureOrigin != nil { r.JobInfo.FailureReason.FailureOrigin = types.StringValue(string(*resp.JobInfo.FailureReason.FailureOrigin)) } else { @@ -275,26 +215,20 @@ func (r *SourceSchemaDataSourceModel) RefreshFromGetResponse(resp *shared.Source } else { r.JobInfo.FailureReason.FailureType = types.StringNull() } - if resp.JobInfo.FailureReason.ExternalMessage != nil { - r.JobInfo.FailureReason.ExternalMessage = types.StringValue(*resp.JobInfo.FailureReason.ExternalMessage) - } else { - r.JobInfo.FailureReason.ExternalMessage = types.StringNull() - } - if resp.JobInfo.FailureReason.InternalMessage != nil { - r.JobInfo.FailureReason.InternalMessage = types.StringValue(*resp.JobInfo.FailureReason.InternalMessage) - } else { - r.JobInfo.FailureReason.InternalMessage = types.StringNull() - } - if resp.JobInfo.FailureReason.Stacktrace != nil { - r.JobInfo.FailureReason.Stacktrace = types.StringValue(*resp.JobInfo.FailureReason.Stacktrace) - } else { - r.JobInfo.FailureReason.Stacktrace = types.StringNull() - } - if resp.JobInfo.FailureReason.Retryable != nil { - r.JobInfo.FailureReason.Retryable = types.BoolValue(*resp.JobInfo.FailureReason.Retryable) - } else { - r.JobInfo.FailureReason.Retryable = types.BoolNull() - } + r.JobInfo.FailureReason.InternalMessage = types.StringPointerValue(resp.JobInfo.FailureReason.InternalMessage) + r.JobInfo.FailureReason.Retryable = types.BoolPointerValue(resp.JobInfo.FailureReason.Retryable) + r.JobInfo.FailureReason.Stacktrace = types.StringPointerValue(resp.JobInfo.FailureReason.Stacktrace) r.JobInfo.FailureReason.Timestamp = types.Int64Value(resp.JobInfo.FailureReason.Timestamp) } + r.JobInfo.ID = types.StringValue(resp.JobInfo.ID) + if resp.JobInfo.Logs == nil { + r.JobInfo.Logs = nil + } else { + r.JobInfo.Logs = &LogRead{} + r.JobInfo.Logs.LogLines = nil + for _, v := range resp.JobInfo.Logs.LogLines { + r.JobInfo.Logs.LogLines = append(r.JobInfo.Logs.LogLines, types.StringValue(v)) + } + } + r.JobInfo.Succeeded = types.BoolValue(resp.JobInfo.Succeeded) } diff --git a/internal/provider/type_destination_definition_create.go b/internal/provider/type_destination_definition_create.go deleted file mode 100644 index fea4830..0000000 --- a/internal/provider/type_destination_definition_create.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. - -package provider - -import "github.com/hashicorp/terraform-plugin-framework/types" - -type DestinationDefinitionCreate struct { - Name types.String `tfsdk:"name"` - DockerRepository types.String `tfsdk:"docker_repository"` - DockerImageTag types.String `tfsdk:"docker_image_tag"` - DocumentationURL types.String `tfsdk:"documentation_url"` - Icon types.String `tfsdk:"icon"` - ResourceRequirements *ActorDefinitionResourceRequirements `tfsdk:"resource_requirements"` -} diff --git a/internal/provider/type_failure_reason.go b/internal/provider/type_failure_reason.go index 5e1a08b..8c48f48 100644 --- a/internal/provider/type_failure_reason.go +++ b/internal/provider/type_failure_reason.go @@ -5,11 +5,11 @@ package provider import "github.com/hashicorp/terraform-plugin-framework/types" type FailureReason struct { + ExternalMessage types.String `tfsdk:"external_message"` FailureOrigin types.String `tfsdk:"failure_origin"` FailureType types.String `tfsdk:"failure_type"` - ExternalMessage types.String `tfsdk:"external_message"` InternalMessage types.String `tfsdk:"internal_message"` - Stacktrace types.String `tfsdk:"stacktrace"` Retryable types.Bool `tfsdk:"retryable"` + Stacktrace types.String `tfsdk:"stacktrace"` Timestamp types.Int64 `tfsdk:"timestamp"` } diff --git a/internal/provider/type_field_schema_update.go b/internal/provider/type_field_schema_update.go index 3e8bc80..3028afa 100644 --- a/internal/provider/type_field_schema_update.go +++ b/internal/provider/type_field_schema_update.go @@ -3,6 +3,6 @@ package provider type FieldSchemaUpdate struct { - OldSchema DeclarativeManifest `tfsdk:"old_schema"` NewSchema DeclarativeManifest `tfsdk:"new_schema"` + OldSchema DeclarativeManifest `tfsdk:"old_schema"` } diff --git a/internal/provider/type_field_transform.go b/internal/provider/type_field_transform.go index 6872765..e63bab8 100644 --- a/internal/provider/type_field_transform.go +++ b/internal/provider/type_field_transform.go @@ -5,10 +5,10 @@ package provider import "github.com/hashicorp/terraform-plugin-framework/types" type FieldTransform struct { - TransformType types.String `tfsdk:"transform_type"` - FieldName []types.String `tfsdk:"field_name"` - Breaking types.Bool `tfsdk:"breaking"` AddField *FieldAdd `tfsdk:"add_field"` + Breaking types.Bool `tfsdk:"breaking"` + FieldName []types.String `tfsdk:"field_name"` RemoveField *FieldAdd `tfsdk:"remove_field"` + TransformType types.String `tfsdk:"transform_type"` UpdateFieldSchema *FieldSchemaUpdate `tfsdk:"update_field_schema"` } diff --git a/internal/provider/type_stream_transform.go b/internal/provider/type_stream_transform.go index 269522d..1e34ef1 100644 --- a/internal/provider/type_stream_transform.go +++ b/internal/provider/type_stream_transform.go @@ -5,7 +5,7 @@ package provider import "github.com/hashicorp/terraform-plugin-framework/types" type StreamTransform struct { - TransformType types.String `tfsdk:"transform_type"` StreamDescriptor StreamDescriptor `tfsdk:"stream_descriptor"` + TransformType types.String `tfsdk:"transform_type"` UpdateStream []FieldTransform `tfsdk:"update_stream"` } diff --git a/internal/provider/type_synchronous_job_read.go b/internal/provider/type_synchronous_job_read.go index 5da35e0..eae6822 100644 --- a/internal/provider/type_synchronous_job_read.go +++ b/internal/provider/type_synchronous_job_read.go @@ -5,13 +5,13 @@ package provider import "github.com/hashicorp/terraform-plugin-framework/types" type SynchronousJobRead struct { - ID types.String `tfsdk:"id"` - ConfigType types.String `tfsdk:"config_type"` ConfigID types.String `tfsdk:"config_id"` + ConfigType types.String `tfsdk:"config_type"` + ConnectorConfigurationUpdated types.Bool `tfsdk:"connector_configuration_updated"` CreatedAt types.Int64 `tfsdk:"created_at"` EndedAt types.Int64 `tfsdk:"ended_at"` - Succeeded types.Bool `tfsdk:"succeeded"` - ConnectorConfigurationUpdated types.Bool `tfsdk:"connector_configuration_updated"` - Logs *LogRead `tfsdk:"logs"` FailureReason *FailureReason `tfsdk:"failure_reason"` + ID types.String `tfsdk:"id"` + Logs *LogRead `tfsdk:"logs"` + Succeeded types.Bool `tfsdk:"succeeded"` } diff --git a/internal/provider/utils.go b/internal/provider/utils.go index cc623ed..75e3038 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -69,15 +69,17 @@ func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.Updat return } - // we need a tftypes.Value for this Object to be able to use it with - // our reflection code + refreshPlan(ctx, plan, target, resp.Diagnostics) +} + +func refreshPlan(ctx context.Context, plan types.Object, target interface{}, diagnostics diag.Diagnostics) { obj := types.ObjectType{AttrTypes: plan.AttributeTypes(ctx)} val, err := plan.ToTerraformValue(ctx) if err != nil { - resp.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())) + 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 } - resp.Diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ + diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, }, path.Empty())...) diff --git a/internal/provider/workspace_data_source.go b/internal/provider/workspace_data_source.go index 6e59479..16d38ba 100644 --- a/internal/provider/workspace_data_source.go +++ b/internal/provider/workspace_data_source.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -94,17 +93,19 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.StringAttribute{ Computed: true, Description: `must be one of ["slack", "customerio"]`, }, - "send_on_success": schema.BoolAttribute{ - Computed: true, - Description: `Default: false`, - }, "send_on_failure": schema.BoolAttribute{ - Computed: true, - Description: `Default: true`, + Computed: true, + }, + "send_on_success": schema.BoolAttribute{ + Computed: true, }, "slack_configuration": schema.SingleNestedAttribute{ Computed: true, @@ -114,19 +115,19 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, }, "notification_settings": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ - "send_on_success": schema.SingleNestedAttribute{ + "send_on_breaking_change_syncs_disabled": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -139,15 +140,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_failure": schema.SingleNestedAttribute{ + "send_on_breaking_change_warning": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -160,15 +161,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_sync_disabled": schema.SingleNestedAttribute{ + "send_on_connection_update": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -181,15 +182,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_sync_disabled_warning": schema.SingleNestedAttribute{ + "send_on_connection_update_action_required": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -202,15 +203,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_connection_update": schema.SingleNestedAttribute{ + "send_on_failure": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -223,15 +224,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_connection_update_action_required": schema.SingleNestedAttribute{ + "send_on_success": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -244,15 +245,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_breaking_change_warning": schema.SingleNestedAttribute{ + "send_on_sync_disabled": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -265,15 +266,15 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, - "send_on_breaking_change_syncs_disabled": schema.SingleNestedAttribute{ + "send_on_sync_disabled_warning": schema.SingleNestedAttribute{ Computed: true, Attributes: map[string]schema.Attribute{ + "customerio_configuration": schema.SingleNestedAttribute{ + Computed: true, + Attributes: map[string]schema.Attribute{}, + }, "notification_type": schema.ListAttribute{ Computed: true, ElementType: types.StringType, @@ -286,10 +287,6 @@ func (r *WorkspaceDataSource) Schema(ctx context.Context, req datasource.SchemaR }, }, }, - "customerio_configuration": schema.SingleNestedAttribute{ - Computed: true, - Attributes: map[string]schema.Attribute{}, - }, }, }, }, @@ -386,7 +383,7 @@ func (r *WorkspaceDataSource) Read(ctx context.Context, req datasource.ReadReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.WorkspaceRead) + data.RefreshFromSharedWorkspaceRead(res.WorkspaceRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/workspace_data_source_sdk.go b/internal/provider/workspace_data_source_sdk.go index dfd0b48..94942d8 100644 --- a/internal/provider/workspace_data_source_sdk.go +++ b/internal/provider/workspace_data_source_sdk.go @@ -7,170 +7,103 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *WorkspaceDataSourceModel) RefreshFromGetResponse(resp *shared.WorkspaceRead) { - if resp.AnonymousDataCollection != nil { - r.AnonymousDataCollection = types.BoolValue(*resp.AnonymousDataCollection) - } else { - r.AnonymousDataCollection = types.BoolNull() - } +func (r *WorkspaceDataSourceModel) RefreshFromSharedWorkspaceRead(resp *shared.WorkspaceRead) { + r.AnonymousDataCollection = types.BoolPointerValue(resp.AnonymousDataCollection) r.CustomerID = types.StringValue(resp.CustomerID) if resp.DefaultGeography != nil { r.DefaultGeography = types.StringValue(string(*resp.DefaultGeography)) } else { r.DefaultGeography = types.StringNull() } - if resp.DisplaySetupWizard != nil { - r.DisplaySetupWizard = types.BoolValue(*resp.DisplaySetupWizard) - } else { - r.DisplaySetupWizard = types.BoolNull() - } - if resp.Email != nil { - r.Email = types.StringValue(*resp.Email) - } else { - r.Email = types.StringNull() - } - if resp.FeedbackDone != nil { - r.FeedbackDone = types.BoolValue(*resp.FeedbackDone) - } else { - r.FeedbackDone = types.BoolNull() - } - if resp.FirstCompletedSync != nil { - r.FirstCompletedSync = types.BoolValue(*resp.FirstCompletedSync) - } else { - r.FirstCompletedSync = types.BoolNull() - } + r.DisplaySetupWizard = types.BoolPointerValue(resp.DisplaySetupWizard) + r.Email = types.StringPointerValue(resp.Email) + r.FeedbackDone = types.BoolPointerValue(resp.FeedbackDone) + r.FirstCompletedSync = types.BoolPointerValue(resp.FirstCompletedSync) r.InitialSetupComplete = types.BoolValue(resp.InitialSetupComplete) r.Name = types.StringValue(resp.Name) - if resp.News != nil { - r.News = types.BoolValue(*resp.News) - } else { - r.News = types.BoolNull() - } + r.News = types.BoolPointerValue(resp.News) if len(r.Notifications) > len(resp.Notifications) { r.Notifications = r.Notifications[:len(resp.Notifications)] } for notificationsCount, notificationsItem := range resp.Notifications { var notifications1 Notification - notifications1.NotificationType = types.StringValue(string(notificationsItem.NotificationType)) - if notificationsItem.SendOnSuccess != nil { - notifications1.SendOnSuccess = types.BoolValue(*notificationsItem.SendOnSuccess) - } else { - notifications1.SendOnSuccess = types.BoolNull() - } - if notificationsItem.SendOnFailure != nil { - notifications1.SendOnFailure = types.BoolValue(*notificationsItem.SendOnFailure) + if notificationsItem.CustomerioConfiguration == nil { + notifications1.CustomerioConfiguration = nil } else { - notifications1.SendOnFailure = types.BoolNull() + notifications1.CustomerioConfiguration = &DeclarativeManifest{} } + notifications1.NotificationType = types.StringValue(string(notificationsItem.NotificationType)) + notifications1.SendOnFailure = types.BoolPointerValue(notificationsItem.SendOnFailure) + notifications1.SendOnSuccess = types.BoolPointerValue(notificationsItem.SendOnSuccess) if notificationsItem.SlackConfiguration == nil { notifications1.SlackConfiguration = nil } else { notifications1.SlackConfiguration = &SlackNotificationConfiguration{} notifications1.SlackConfiguration.Webhook = types.StringValue(notificationsItem.SlackConfiguration.Webhook) } - if notificationsItem.CustomerioConfiguration == nil { - notifications1.CustomerioConfiguration = nil - } else { - notifications1.CustomerioConfiguration = &DeclarativeManifest{} - } if notificationsCount+1 > len(r.Notifications) { r.Notifications = append(r.Notifications, notifications1) } else { + r.Notifications[notificationsCount].CustomerioConfiguration = notifications1.CustomerioConfiguration r.Notifications[notificationsCount].NotificationType = notifications1.NotificationType - r.Notifications[notificationsCount].SendOnSuccess = notifications1.SendOnSuccess r.Notifications[notificationsCount].SendOnFailure = notifications1.SendOnFailure + r.Notifications[notificationsCount].SendOnSuccess = notifications1.SendOnSuccess r.Notifications[notificationsCount].SlackConfiguration = notifications1.SlackConfiguration - r.Notifications[notificationsCount].CustomerioConfiguration = notifications1.CustomerioConfiguration } } if resp.NotificationSettings == nil { r.NotificationSettings = nil } else { r.NotificationSettings = &NotificationSettings{} - if resp.NotificationSettings.SendOnSuccess == nil { - r.NotificationSettings.SendOnSuccess = nil + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = nil } else { - r.NotificationSettings.SendOnSuccess = &NotificationItem{} - r.NotificationSettings.SendOnSuccess.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSuccess.NotificationType { - r.NotificationSettings.SendOnSuccess.NotificationType = append(r.NotificationSettings.SendOnSuccess.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnSuccess.SlackConfiguration == nil { - r.NotificationSettings.SendOnSuccess.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSuccess.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook) - } - if resp.NotificationSettings.SendOnSuccess.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = nil + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = &NotificationItem{} + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = nil } else { - r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = &DeclarativeManifest{} - } - } - if resp.NotificationSettings.SendOnFailure == nil { - r.NotificationSettings.SendOnFailure = nil - } else { - r.NotificationSettings.SendOnFailure = &NotificationItem{} - r.NotificationSettings.SendOnFailure.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnFailure.NotificationType { - r.NotificationSettings.SendOnFailure.NotificationType = append(r.NotificationSettings.SendOnFailure.NotificationType, types.StringValue(string(v))) + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = &DeclarativeManifest{} } - if resp.NotificationSettings.SendOnFailure.SlackConfiguration == nil { - r.NotificationSettings.SendOnFailure.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnFailure.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook) + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType, types.StringValue(string(v))) } - if resp.NotificationSettings.SendOnFailure.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnFailure.CustomerioConfiguration = nil + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = nil } else { - r.NotificationSettings.SendOnFailure.CustomerioConfiguration = &DeclarativeManifest{} + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook) } } - if resp.NotificationSettings.SendOnSyncDisabled == nil { - r.NotificationSettings.SendOnSyncDisabled = nil + if resp.NotificationSettings.SendOnBreakingChangeWarning == nil { + r.NotificationSettings.SendOnBreakingChangeWarning = nil } else { - r.NotificationSettings.SendOnSyncDisabled = &NotificationItem{} - r.NotificationSettings.SendOnSyncDisabled.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSyncDisabled.NotificationType { - r.NotificationSettings.SendOnSyncDisabled.NotificationType = append(r.NotificationSettings.SendOnSyncDisabled.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook) - } - if resp.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = nil + r.NotificationSettings.SendOnBreakingChangeWarning = &NotificationItem{} + if resp.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = nil } else { - r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = &DeclarativeManifest{} - } - } - if resp.NotificationSettings.SendOnSyncDisabledWarning == nil { - r.NotificationSettings.SendOnSyncDisabledWarning = nil - } else { - r.NotificationSettings.SendOnSyncDisabledWarning = &NotificationItem{} - r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSyncDisabledWarning.NotificationType { - r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = append(r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType, types.StringValue(string(v))) + r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = &DeclarativeManifest{} } - if resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook) + r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnBreakingChangeWarning.NotificationType { + r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType, types.StringValue(string(v))) } - if resp.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = nil + if resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = nil } else { - r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = &DeclarativeManifest{} + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook) } } if resp.NotificationSettings.SendOnConnectionUpdate == nil { r.NotificationSettings.SendOnConnectionUpdate = nil } else { r.NotificationSettings.SendOnConnectionUpdate = &NotificationItem{} + if resp.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = &DeclarativeManifest{} + } r.NotificationSettings.SendOnConnectionUpdate.NotificationType = nil for _, v := range resp.NotificationSettings.SendOnConnectionUpdate.NotificationType { r.NotificationSettings.SendOnConnectionUpdate.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdate.NotificationType, types.StringValue(string(v))) @@ -181,16 +114,16 @@ func (r *WorkspaceDataSourceModel) RefreshFromGetResponse(resp *shared.Workspace r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration = &SlackNotificationConfiguration{} r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook) } - if resp.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = &DeclarativeManifest{} - } } if resp.NotificationSettings.SendOnConnectionUpdateActionRequired == nil { r.NotificationSettings.SendOnConnectionUpdateActionRequired = nil } else { r.NotificationSettings.SendOnConnectionUpdateActionRequired = &NotificationItem{} + if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = &DeclarativeManifest{} + } r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = nil for _, v := range resp.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType { r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType, types.StringValue(string(v))) @@ -201,63 +134,90 @@ func (r *WorkspaceDataSourceModel) RefreshFromGetResponse(resp *shared.Workspace r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration = &SlackNotificationConfiguration{} r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook) } - if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = nil + } + if resp.NotificationSettings.SendOnFailure == nil { + r.NotificationSettings.SendOnFailure = nil + } else { + r.NotificationSettings.SendOnFailure = &NotificationItem{} + if resp.NotificationSettings.SendOnFailure.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnFailure.CustomerioConfiguration = nil } else { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = &DeclarativeManifest{} + r.NotificationSettings.SendOnFailure.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnFailure.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnFailure.NotificationType { + r.NotificationSettings.SendOnFailure.NotificationType = append(r.NotificationSettings.SendOnFailure.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnFailure.SlackConfiguration == nil { + r.NotificationSettings.SendOnFailure.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnFailure.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook) } } - if resp.NotificationSettings.SendOnBreakingChangeWarning == nil { - r.NotificationSettings.SendOnBreakingChangeWarning = nil + if resp.NotificationSettings.SendOnSuccess == nil { + r.NotificationSettings.SendOnSuccess = nil } else { - r.NotificationSettings.SendOnBreakingChangeWarning = &NotificationItem{} - r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnBreakingChangeWarning.NotificationType { - r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = nil + r.NotificationSettings.SendOnSuccess = &NotificationItem{} + if resp.NotificationSettings.SendOnSuccess.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = nil } else { - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook) + r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = &DeclarativeManifest{} } - if resp.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = nil + r.NotificationSettings.SendOnSuccess.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSuccess.NotificationType { + r.NotificationSettings.SendOnSuccess.NotificationType = append(r.NotificationSettings.SendOnSuccess.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSuccess.SlackConfiguration == nil { + r.NotificationSettings.SendOnSuccess.SlackConfiguration = nil } else { - r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = &DeclarativeManifest{} + r.NotificationSettings.SendOnSuccess.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook) } } - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = nil + if resp.NotificationSettings.SendOnSyncDisabled == nil { + r.NotificationSettings.SendOnSyncDisabled = nil } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = &NotificationItem{} - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType, types.StringValue(string(v))) + r.NotificationSettings.SendOnSyncDisabled = &NotificationItem{} + if resp.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = &DeclarativeManifest{} } - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = nil + r.NotificationSettings.SendOnSyncDisabled.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSyncDisabled.NotificationType { + r.NotificationSettings.SendOnSyncDisabled.NotificationType = append(r.NotificationSettings.SendOnSyncDisabled.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = nil } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook) + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook) } - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = nil + } + if resp.NotificationSettings.SendOnSyncDisabledWarning == nil { + r.NotificationSettings.SendOnSyncDisabledWarning = nil + } else { + r.NotificationSettings.SendOnSyncDisabledWarning = &NotificationItem{} + if resp.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = nil } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = &DeclarativeManifest{} + r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSyncDisabledWarning.NotificationType { + r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = append(r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook) } } } - if resp.OrganizationID != nil { - r.OrganizationID = types.StringValue(*resp.OrganizationID) - } else { - r.OrganizationID = types.StringNull() - } - if resp.SecurityUpdates != nil { - r.SecurityUpdates = types.BoolValue(*resp.SecurityUpdates) - } else { - r.SecurityUpdates = types.BoolNull() - } + r.OrganizationID = types.StringPointerValue(resp.OrganizationID) + r.SecurityUpdates = types.BoolPointerValue(resp.SecurityUpdates) r.Slug = types.StringValue(resp.Slug) if len(r.WebhookConfigs) > len(resp.WebhookConfigs) { r.WebhookConfigs = r.WebhookConfigs[:len(resp.WebhookConfigs)] @@ -265,11 +225,7 @@ func (r *WorkspaceDataSourceModel) RefreshFromGetResponse(resp *shared.Workspace for webhookConfigsCount, webhookConfigsItem := range resp.WebhookConfigs { var webhookConfigs1 WebhookConfigRead1 webhookConfigs1.ID = types.StringValue(webhookConfigsItem.ID) - if webhookConfigsItem.Name != nil { - webhookConfigs1.Name = types.StringValue(*webhookConfigsItem.Name) - } else { - webhookConfigs1.Name = types.StringNull() - } + webhookConfigs1.Name = types.StringPointerValue(webhookConfigsItem.Name) if webhookConfigsCount+1 > len(r.WebhookConfigs) { r.WebhookConfigs = append(r.WebhookConfigs, webhookConfigs1) } else { diff --git a/internal/provider/workspace_resource.go b/internal/provider/workspace_resource.go index 7c2441f..744928c 100644 --- a/internal/provider/workspace_resource.go +++ b/internal/provider/workspace_resource.go @@ -5,13 +5,15 @@ package provider import ( "context" "fmt" + speakeasy_stringplanmodifier "github.com/aballiet/terraform-provider-airbyte/internal/planmodifiers/stringplanmodifier" "github.com/aballiet/terraform-provider-airbyte/internal/sdk" - "github.com/aballiet/terraform-provider-airbyte/internal/sdk/pkg/models/shared" + speakeasy_stringvalidators "github.com/aballiet/terraform-provider-airbyte/internal/validators/stringvalidators" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -100,9 +102,11 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque }, "name": schema.StringAttribute{ PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Required: true, + Required: true, + Description: `Requires replacement if changed. `, }, "news": schema.BoolAttribute{ Computed: true, @@ -119,9 +123,11 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Attributes: map[string]schema.Attribute{}, }, "notification_type": schema.StringAttribute{ - Required: true, - Description: `must be one of ["slack", "customerio"]`, + Computed: true, + Optional: true, + Description: `Not Null; must be one of ["slack", "customerio"]`, Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), stringvalidator.OneOf( "slack", "customerio", @@ -131,11 +137,13 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque "send_on_failure": schema.BoolAttribute{ Computed: true, Optional: true, + Default: booldefault.StaticBool(true), Description: `Default: true`, }, "send_on_success": schema.BoolAttribute{ Computed: true, Optional: true, + Default: booldefault.StaticBool(false), Description: `Default: false`, }, "slack_configuration": schema.SingleNestedAttribute{ @@ -143,7 +151,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -173,7 +186,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -198,7 +216,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -223,7 +246,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -248,7 +276,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -273,7 +306,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -298,7 +336,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -323,7 +366,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -348,7 +396,12 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Optional: true, Attributes: map[string]schema.Attribute{ "webhook": schema.StringAttribute{ - Required: true, + Computed: true, + Optional: true, + Description: `Not Null`, + Validators: []validator.String{ + speakeasy_stringvalidators.NotNull(), + }, }, }, }, @@ -359,9 +412,11 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque "organization_id": schema.StringAttribute{ Computed: true, PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + stringplanmodifier.RequiresReplaceIfConfigured(), + speakeasy_stringplanmodifier.SuppressDiff(speakeasy_stringplanmodifier.ExplicitSuppress), }, - Optional: true, + Optional: true, + Description: `Requires replacement if changed. `, }, "security_updates": schema.BoolAttribute{ Computed: true, @@ -376,6 +431,7 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "auth_token": schema.StringAttribute{ + Computed: true, Optional: true, Description: `an auth token, to be passed as the value for an HTTP Authorization header.`, }, @@ -388,6 +444,7 @@ func (r *WorkspaceResource) Schema(ctx context.Context, req resource.SchemaReque Description: `human readable name for this webhook e.g. for UI display.`, }, "validation_url": schema.StringAttribute{ + Computed: true, Optional: true, Description: `if supplied, the webhook config will be validated by checking that this URL returns a 2xx response.`, }, @@ -423,14 +480,14 @@ func (r *WorkspaceResource) Configure(ctx context.Context, req resource.Configur func (r *WorkspaceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { var data *WorkspaceResourceModel - var item types.Object + var plan types.Object - resp.Diagnostics.Append(req.Plan.Get(ctx, &item)...) + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) if resp.Diagnostics.HasError() { return } - resp.Diagnostics.Append(item.As(ctx, &data, basetypes.ObjectAsOptions{ + resp.Diagnostics.Append(plan.As(ctx, &data, basetypes.ObjectAsOptions{ UnhandledNullAsEmpty: true, UnhandledUnknownAsEmpty: true, })...) @@ -439,7 +496,7 @@ func (r *WorkspaceResource) Create(ctx context.Context, req resource.CreateReque return } - request := *data.ToCreateSDKType() + request := *data.ToSharedWorkspaceCreate() res, err := r.client.Workspace.CreateWorkspace(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -460,7 +517,34 @@ func (r *WorkspaceResource) Create(ctx context.Context, req resource.CreateReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromCreateResponse(res.WorkspaceRead) + data.RefreshFromSharedWorkspaceRead(res.WorkspaceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + workspaceID := data.WorkspaceID.ValueString() + request1 := shared.WorkspaceIDRequestBody{ + WorkspaceID: workspaceID, + } + res1, err := r.client.Workspace.GetWorkspace(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.WorkspaceRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedWorkspaceRead(res1.WorkspaceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -508,7 +592,7 @@ func (r *WorkspaceResource) Read(ctx context.Context, req resource.ReadRequest, resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromGetResponse(res.WorkspaceRead) + data.RefreshFromSharedWorkspaceRead(res.WorkspaceRead) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -516,12 +600,19 @@ func (r *WorkspaceResource) Read(ctx context.Context, req resource.ReadRequest, func (r *WorkspaceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { var data *WorkspaceResourceModel + var plan types.Object + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + merge(ctx, req, resp, &data) if resp.Diagnostics.HasError() { return } - request := *data.ToUpdateSDKType() + request := *data.ToSharedWorkspaceUpdate() res, err := r.client.Workspace.UpdateWorkspace(ctx, request) if err != nil { resp.Diagnostics.AddError("failure to invoke API", err.Error()) @@ -542,7 +633,34 @@ func (r *WorkspaceResource) Update(ctx context.Context, req resource.UpdateReque resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res.RawResponse)) return } - data.RefreshFromUpdateResponse(res.WorkspaceRead) + data.RefreshFromSharedWorkspaceRead(res.WorkspaceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) + workspaceID := data.WorkspaceID.ValueString() + request1 := shared.WorkspaceIDRequestBody{ + WorkspaceID: workspaceID, + } + res1, err := r.client.Workspace.GetWorkspace(ctx, request1) + if err != nil { + resp.Diagnostics.AddError("failure to invoke API", err.Error()) + if res1 != nil && res1.RawResponse != nil { + resp.Diagnostics.AddError("unexpected http request/response", debugResponse(res1.RawResponse)) + } + return + } + if res1 == nil { + resp.Diagnostics.AddError("unexpected response from API", fmt.Sprintf("%v", res1)) + return + } + if res1.StatusCode != 200 { + resp.Diagnostics.AddError(fmt.Sprintf("unexpected response from API. Got an unexpected response code %v", res1.StatusCode), debugResponse(res1.RawResponse)) + return + } + if res1.WorkspaceRead == nil { + resp.Diagnostics.AddError("unexpected response from API. No response body", debugResponse(res1.RawResponse)) + return + } + data.RefreshFromSharedWorkspaceRead(res1.WorkspaceRead) + refreshPlan(ctx, plan, &data, resp.Diagnostics) // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) diff --git a/internal/provider/workspace_resource_sdk.go b/internal/provider/workspace_resource_sdk.go index 05c96a7..b06faba 100644 --- a/internal/provider/workspace_resource_sdk.go +++ b/internal/provider/workspace_resource_sdk.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func (r *WorkspaceResourceModel) ToCreateSDKType() *shared.WorkspaceCreate { +func (r *WorkspaceResourceModel) ToSharedWorkspaceCreate() *shared.WorkspaceCreate { email := new(string) if !r.Email.IsUnknown() && !r.Email.IsNull() { *email = r.Email.ValueString() @@ -324,12 +324,236 @@ func (r *WorkspaceResourceModel) ToCreateSDKType() *shared.WorkspaceCreate { return &out } -func (r *WorkspaceResourceModel) ToGetSDKType() *shared.WorkspaceCreate { - out := r.ToCreateSDKType() - return out +func (r *WorkspaceResourceModel) RefreshFromSharedWorkspaceRead(resp *shared.WorkspaceRead) { + r.AnonymousDataCollection = types.BoolPointerValue(resp.AnonymousDataCollection) + r.CustomerID = types.StringValue(resp.CustomerID) + if resp.DefaultGeography != nil { + r.DefaultGeography = types.StringValue(string(*resp.DefaultGeography)) + } else { + r.DefaultGeography = types.StringNull() + } + r.DisplaySetupWizard = types.BoolPointerValue(resp.DisplaySetupWizard) + r.Email = types.StringPointerValue(resp.Email) + r.FeedbackDone = types.BoolPointerValue(resp.FeedbackDone) + r.FirstCompletedSync = types.BoolPointerValue(resp.FirstCompletedSync) + r.InitialSetupComplete = types.BoolValue(resp.InitialSetupComplete) + r.Name = types.StringValue(resp.Name) + r.News = types.BoolPointerValue(resp.News) + if len(r.Notifications) > len(resp.Notifications) { + r.Notifications = r.Notifications[:len(resp.Notifications)] + } + for notificationsCount, notificationsItem := range resp.Notifications { + var notifications1 Notification + if notificationsItem.CustomerioConfiguration == nil { + notifications1.CustomerioConfiguration = nil + } else { + notifications1.CustomerioConfiguration = &DeclarativeManifest{} + } + notifications1.NotificationType = types.StringValue(string(notificationsItem.NotificationType)) + notifications1.SendOnFailure = types.BoolPointerValue(notificationsItem.SendOnFailure) + notifications1.SendOnSuccess = types.BoolPointerValue(notificationsItem.SendOnSuccess) + if notificationsItem.SlackConfiguration == nil { + notifications1.SlackConfiguration = nil + } else { + notifications1.SlackConfiguration = &SlackNotificationConfiguration{} + notifications1.SlackConfiguration.Webhook = types.StringValue(notificationsItem.SlackConfiguration.Webhook) + } + if notificationsCount+1 > len(r.Notifications) { + r.Notifications = append(r.Notifications, notifications1) + } else { + r.Notifications[notificationsCount].CustomerioConfiguration = notifications1.CustomerioConfiguration + r.Notifications[notificationsCount].NotificationType = notifications1.NotificationType + r.Notifications[notificationsCount].SendOnFailure = notifications1.SendOnFailure + r.Notifications[notificationsCount].SendOnSuccess = notifications1.SendOnSuccess + r.Notifications[notificationsCount].SlackConfiguration = notifications1.SlackConfiguration + } + } + if resp.NotificationSettings == nil { + r.NotificationSettings = nil + } else { + r.NotificationSettings = &NotificationSettings{} + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = nil + } else { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = &NotificationItem{} + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnBreakingChangeWarning == nil { + r.NotificationSettings.SendOnBreakingChangeWarning = nil + } else { + r.NotificationSettings.SendOnBreakingChangeWarning = &NotificationItem{} + if resp.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnBreakingChangeWarning.NotificationType { + r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration == nil { + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnConnectionUpdate == nil { + r.NotificationSettings.SendOnConnectionUpdate = nil + } else { + r.NotificationSettings.SendOnConnectionUpdate = &NotificationItem{} + if resp.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnConnectionUpdate.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnConnectionUpdate.NotificationType { + r.NotificationSettings.SendOnConnectionUpdate.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdate.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnConnectionUpdateActionRequired == nil { + r.NotificationSettings.SendOnConnectionUpdateActionRequired = nil + } else { + r.NotificationSettings.SendOnConnectionUpdateActionRequired = &NotificationItem{} + if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration == nil { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnFailure == nil { + r.NotificationSettings.SendOnFailure = nil + } else { + r.NotificationSettings.SendOnFailure = &NotificationItem{} + if resp.NotificationSettings.SendOnFailure.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnFailure.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnFailure.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnFailure.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnFailure.NotificationType { + r.NotificationSettings.SendOnFailure.NotificationType = append(r.NotificationSettings.SendOnFailure.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnFailure.SlackConfiguration == nil { + r.NotificationSettings.SendOnFailure.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnFailure.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnSuccess == nil { + r.NotificationSettings.SendOnSuccess = nil + } else { + r.NotificationSettings.SendOnSuccess = &NotificationItem{} + if resp.NotificationSettings.SendOnSuccess.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnSuccess.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSuccess.NotificationType { + r.NotificationSettings.SendOnSuccess.NotificationType = append(r.NotificationSettings.SendOnSuccess.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSuccess.SlackConfiguration == nil { + r.NotificationSettings.SendOnSuccess.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnSuccess.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnSyncDisabled == nil { + r.NotificationSettings.SendOnSyncDisabled = nil + } else { + r.NotificationSettings.SendOnSyncDisabled = &NotificationItem{} + if resp.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnSyncDisabled.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSyncDisabled.NotificationType { + r.NotificationSettings.SendOnSyncDisabled.NotificationType = append(r.NotificationSettings.SendOnSyncDisabled.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook) + } + } + if resp.NotificationSettings.SendOnSyncDisabledWarning == nil { + r.NotificationSettings.SendOnSyncDisabledWarning = nil + } else { + r.NotificationSettings.SendOnSyncDisabledWarning = &NotificationItem{} + if resp.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = &DeclarativeManifest{} + } + r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = nil + for _, v := range resp.NotificationSettings.SendOnSyncDisabledWarning.NotificationType { + r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = append(r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType, types.StringValue(string(v))) + } + if resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration == nil { + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = nil + } else { + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = &SlackNotificationConfiguration{} + r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook) + } + } + } + r.OrganizationID = types.StringPointerValue(resp.OrganizationID) + r.SecurityUpdates = types.BoolPointerValue(resp.SecurityUpdates) + r.Slug = types.StringValue(resp.Slug) + if len(r.WebhookConfigs) > len(resp.WebhookConfigs) { + r.WebhookConfigs = r.WebhookConfigs[:len(resp.WebhookConfigs)] + } + for webhookConfigsCount, webhookConfigsItem := range resp.WebhookConfigs { + var webhookConfigs1 WebhookConfigRead + webhookConfigs1.ID = types.StringValue(webhookConfigsItem.ID) + webhookConfigs1.Name = types.StringPointerValue(webhookConfigsItem.Name) + if webhookConfigsCount+1 > len(r.WebhookConfigs) { + r.WebhookConfigs = append(r.WebhookConfigs, webhookConfigs1) + } else { + r.WebhookConfigs[webhookConfigsCount].ID = webhookConfigs1.ID + r.WebhookConfigs[webhookConfigsCount].Name = webhookConfigs1.Name + } + } + r.WorkspaceID = types.StringValue(resp.WorkspaceID) } -func (r *WorkspaceResourceModel) ToUpdateSDKType() *shared.WorkspaceUpdate { +func (r *WorkspaceResourceModel) ToSharedWorkspaceUpdate() *shared.WorkspaceUpdate { workspaceID := r.WorkspaceID.ValueString() email := new(string) if !r.Email.IsUnknown() && !r.Email.IsNull() { @@ -645,289 +869,3 @@ func (r *WorkspaceResourceModel) ToUpdateSDKType() *shared.WorkspaceUpdate { } return &out } - -func (r *WorkspaceResourceModel) ToDeleteSDKType() *shared.WorkspaceCreate { - out := r.ToCreateSDKType() - return out -} - -func (r *WorkspaceResourceModel) RefreshFromGetResponse(resp *shared.WorkspaceRead) { - if resp.AnonymousDataCollection != nil { - r.AnonymousDataCollection = types.BoolValue(*resp.AnonymousDataCollection) - } else { - r.AnonymousDataCollection = types.BoolNull() - } - r.CustomerID = types.StringValue(resp.CustomerID) - if resp.DefaultGeography != nil { - r.DefaultGeography = types.StringValue(string(*resp.DefaultGeography)) - } else { - r.DefaultGeography = types.StringNull() - } - if resp.DisplaySetupWizard != nil { - r.DisplaySetupWizard = types.BoolValue(*resp.DisplaySetupWizard) - } else { - r.DisplaySetupWizard = types.BoolNull() - } - if resp.Email != nil { - r.Email = types.StringValue(*resp.Email) - } else { - r.Email = types.StringNull() - } - if resp.FeedbackDone != nil { - r.FeedbackDone = types.BoolValue(*resp.FeedbackDone) - } else { - r.FeedbackDone = types.BoolNull() - } - if resp.FirstCompletedSync != nil { - r.FirstCompletedSync = types.BoolValue(*resp.FirstCompletedSync) - } else { - r.FirstCompletedSync = types.BoolNull() - } - r.InitialSetupComplete = types.BoolValue(resp.InitialSetupComplete) - r.Name = types.StringValue(resp.Name) - if resp.News != nil { - r.News = types.BoolValue(*resp.News) - } else { - r.News = types.BoolNull() - } - if len(r.Notifications) > len(resp.Notifications) { - r.Notifications = r.Notifications[:len(resp.Notifications)] - } - for notificationsCount, notificationsItem := range resp.Notifications { - var notifications1 Notification - if notificationsItem.CustomerioConfiguration == nil { - notifications1.CustomerioConfiguration = nil - } else { - notifications1.CustomerioConfiguration = &DeclarativeManifest{} - } - notifications1.NotificationType = types.StringValue(string(notificationsItem.NotificationType)) - if notificationsItem.SendOnFailure != nil { - notifications1.SendOnFailure = types.BoolValue(*notificationsItem.SendOnFailure) - } else { - notifications1.SendOnFailure = types.BoolNull() - } - if notificationsItem.SendOnSuccess != nil { - notifications1.SendOnSuccess = types.BoolValue(*notificationsItem.SendOnSuccess) - } else { - notifications1.SendOnSuccess = types.BoolNull() - } - if notificationsItem.SlackConfiguration == nil { - notifications1.SlackConfiguration = nil - } else { - notifications1.SlackConfiguration = &SlackNotificationConfiguration{} - notifications1.SlackConfiguration.Webhook = types.StringValue(notificationsItem.SlackConfiguration.Webhook) - } - if notificationsCount+1 > len(r.Notifications) { - r.Notifications = append(r.Notifications, notifications1) - } else { - r.Notifications[notificationsCount].CustomerioConfiguration = notifications1.CustomerioConfiguration - r.Notifications[notificationsCount].NotificationType = notifications1.NotificationType - r.Notifications[notificationsCount].SendOnFailure = notifications1.SendOnFailure - r.Notifications[notificationsCount].SendOnSuccess = notifications1.SendOnSuccess - r.Notifications[notificationsCount].SlackConfiguration = notifications1.SlackConfiguration - } - } - if resp.NotificationSettings == nil { - r.NotificationSettings = nil - } else { - r.NotificationSettings = &NotificationSettings{} - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = nil - } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled = &NotificationItem{} - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeSyncsDisabled.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnBreakingChangeWarning == nil { - r.NotificationSettings.SendOnBreakingChangeWarning = nil - } else { - r.NotificationSettings.SendOnBreakingChangeWarning = &NotificationItem{} - if resp.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnBreakingChangeWarning.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnBreakingChangeWarning.NotificationType { - r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType = append(r.NotificationSettings.SendOnBreakingChangeWarning.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration == nil { - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnBreakingChangeWarning.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnConnectionUpdate == nil { - r.NotificationSettings.SendOnConnectionUpdate = nil - } else { - r.NotificationSettings.SendOnConnectionUpdate = &NotificationItem{} - if resp.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnConnectionUpdate.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnConnectionUpdate.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnConnectionUpdate.NotificationType { - r.NotificationSettings.SendOnConnectionUpdate.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdate.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdate.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnConnectionUpdateActionRequired == nil { - r.NotificationSettings.SendOnConnectionUpdateActionRequired = nil - } else { - r.NotificationSettings.SendOnConnectionUpdateActionRequired = &NotificationItem{} - if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType = append(r.NotificationSettings.SendOnConnectionUpdateActionRequired.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration == nil { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnConnectionUpdateActionRequired.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnFailure == nil { - r.NotificationSettings.SendOnFailure = nil - } else { - r.NotificationSettings.SendOnFailure = &NotificationItem{} - if resp.NotificationSettings.SendOnFailure.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnFailure.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnFailure.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnFailure.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnFailure.NotificationType { - r.NotificationSettings.SendOnFailure.NotificationType = append(r.NotificationSettings.SendOnFailure.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnFailure.SlackConfiguration == nil { - r.NotificationSettings.SendOnFailure.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnFailure.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnFailure.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnSuccess == nil { - r.NotificationSettings.SendOnSuccess = nil - } else { - r.NotificationSettings.SendOnSuccess = &NotificationItem{} - if resp.NotificationSettings.SendOnSuccess.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnSuccess.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnSuccess.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSuccess.NotificationType { - r.NotificationSettings.SendOnSuccess.NotificationType = append(r.NotificationSettings.SendOnSuccess.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnSuccess.SlackConfiguration == nil { - r.NotificationSettings.SendOnSuccess.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSuccess.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSuccess.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnSyncDisabled == nil { - r.NotificationSettings.SendOnSyncDisabled = nil - } else { - r.NotificationSettings.SendOnSyncDisabled = &NotificationItem{} - if resp.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabled.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnSyncDisabled.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSyncDisabled.NotificationType { - r.NotificationSettings.SendOnSyncDisabled.NotificationType = append(r.NotificationSettings.SendOnSyncDisabled.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabled.SlackConfiguration.Webhook) - } - } - if resp.NotificationSettings.SendOnSyncDisabledWarning == nil { - r.NotificationSettings.SendOnSyncDisabledWarning = nil - } else { - r.NotificationSettings.SendOnSyncDisabledWarning = &NotificationItem{} - if resp.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabledWarning.CustomerioConfiguration = &DeclarativeManifest{} - } - r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = nil - for _, v := range resp.NotificationSettings.SendOnSyncDisabledWarning.NotificationType { - r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType = append(r.NotificationSettings.SendOnSyncDisabledWarning.NotificationType, types.StringValue(string(v))) - } - if resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration == nil { - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = nil - } else { - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration = &SlackNotificationConfiguration{} - r.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook = types.StringValue(resp.NotificationSettings.SendOnSyncDisabledWarning.SlackConfiguration.Webhook) - } - } - } - if resp.OrganizationID != nil { - r.OrganizationID = types.StringValue(*resp.OrganizationID) - } else { - r.OrganizationID = types.StringNull() - } - if resp.SecurityUpdates != nil { - r.SecurityUpdates = types.BoolValue(*resp.SecurityUpdates) - } else { - r.SecurityUpdates = types.BoolNull() - } - r.Slug = types.StringValue(resp.Slug) - if len(r.WebhookConfigs) > len(resp.WebhookConfigs) { - r.WebhookConfigs = r.WebhookConfigs[:len(resp.WebhookConfigs)] - } - for webhookConfigsCount, webhookConfigsItem := range resp.WebhookConfigs { - var webhookConfigs1 WebhookConfigRead - webhookConfigs1.ID = types.StringValue(webhookConfigsItem.ID) - if webhookConfigsItem.Name != nil { - webhookConfigs1.Name = types.StringValue(*webhookConfigsItem.Name) - } else { - webhookConfigs1.Name = types.StringNull() - } - if webhookConfigsCount+1 > len(r.WebhookConfigs) { - r.WebhookConfigs = append(r.WebhookConfigs, webhookConfigs1) - } else { - r.WebhookConfigs[webhookConfigsCount].ID = webhookConfigs1.ID - r.WebhookConfigs[webhookConfigsCount].Name = webhookConfigs1.Name - } - } - r.WorkspaceID = types.StringValue(resp.WorkspaceID) -} - -func (r *WorkspaceResourceModel) RefreshFromCreateResponse(resp *shared.WorkspaceRead) { - r.RefreshFromGetResponse(resp) -} - -func (r *WorkspaceResourceModel) RefreshFromUpdateResponse(resp *shared.WorkspaceRead) { - r.RefreshFromGetResponse(resp) -} diff --git a/internal/sdk/health.go b/internal/sdk/health.go index 72f3284..bb9f5cd 100644 --- a/internal/sdk/health.go +++ b/internal/sdk/health.go @@ -38,7 +38,7 @@ func (s *Health) GetHealthCheck(ctx context.Context) (*operations.GetHealthCheck req.Header.Set("Accept", "application/json") req.Header.Set("user-agent", s.sdkConfiguration.UserAgent) - client := s.sdkConfiguration.SecurityClient + client := s.sdkConfiguration.DefaultClient httpRes, err := client.Do(req) if err != nil { diff --git a/internal/sdk/pkg/models/shared/streamstatusupdaterequestbody.go b/internal/sdk/pkg/models/shared/streamstatusupdaterequestbody.go index 78093ff..476e8d1 100644 --- a/internal/sdk/pkg/models/shared/streamstatusupdaterequestbody.go +++ b/internal/sdk/pkg/models/shared/streamstatusupdaterequestbody.go @@ -3,7 +3,6 @@ package shared type StreamStatusUpdateRequestBody struct { - ID string `json:"id"` AttemptNumber int `json:"attemptNumber"` ConnectionID string `json:"connectionId"` JobID int64 `json:"jobId"` @@ -25,13 +24,7 @@ type StreamStatusUpdateRequestBody struct { StreamNamespace *string `json:"streamNamespace,omitempty"` TransitionedAt int64 `json:"transitionedAt"` WorkspaceID string `json:"workspaceId"` -} - -func (o *StreamStatusUpdateRequestBody) GetID() string { - if o == nil { - return "" - } - return o.ID + ID string `json:"id"` } func (o *StreamStatusUpdateRequestBody) GetAttemptNumber() int { @@ -103,3 +96,10 @@ func (o *StreamStatusUpdateRequestBody) GetWorkspaceID() string { } return o.WorkspaceID } + +func (o *StreamStatusUpdateRequestBody) GetID() string { + if o == nil { + return "" + } + return o.ID +} diff --git a/internal/sdk/pkg/models/shared/updateactivemanifestrequestbody.go b/internal/sdk/pkg/models/shared/updateactivemanifestrequestbody.go index 49e9d9c..d0cee86 100644 --- a/internal/sdk/pkg/models/shared/updateactivemanifestrequestbody.go +++ b/internal/sdk/pkg/models/shared/updateactivemanifestrequestbody.go @@ -5,7 +5,6 @@ package shared type UpdateActiveManifestRequestBody struct { WorkspaceID string `json:"workspaceId"` SourceDefinitionID string `json:"sourceDefinitionId"` - Version int64 `json:"version"` } func (o *UpdateActiveManifestRequestBody) GetWorkspaceID() string { @@ -21,10 +20,3 @@ func (o *UpdateActiveManifestRequestBody) GetSourceDefinitionID() string { } return o.SourceDefinitionID } - -func (o *UpdateActiveManifestRequestBody) GetVersion() int64 { - if o == nil { - return 0 - } - return o.Version -} diff --git a/internal/sdk/pkg/utils/json.go b/internal/sdk/pkg/utils/json.go index 626f13c..655b885 100644 --- a/internal/sdk/pkg/utils/json.go +++ b/internal/sdk/pkg/utils/json.go @@ -358,7 +358,7 @@ func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.Struc return []byte(fmt.Sprintf(`"%s"`, tagValue)) default: if typ.Kind() == reflect.String { - return []byte(fmt.Sprintf(`"%s"`, tagValue)) + return []byte(fmt.Sprintf("%q", tagValue)) } } diff --git a/internal/sdk/pkg/utils/security.go b/internal/sdk/pkg/utils/security.go index fa5eff7..ea1d4b2 100644 --- a/internal/sdk/pkg/utils/security.go +++ b/internal/sdk/pkg/utils/security.go @@ -204,9 +204,9 @@ func parseSecuritySchemeValue(client *securityConfig, schemeTag *securityTag, se panic("not supported") } case "openIdConnect": - client.headers[secTag.Name] = valToString(val) + client.headers[secTag.Name] = prefixBearer(valToString(val)) case "oauth2": - client.headers[secTag.Name] = valToString(val) + client.headers[secTag.Name] = prefixBearer(valToString(val)) case "http": switch schemeTag.SubType { case "bearer": diff --git a/internal/sdk/sdk.go b/internal/sdk/sdk.go index be7d12c..b4fbeee 100644 --- a/internal/sdk/sdk.go +++ b/internal/sdk/sdk.go @@ -217,9 +217,9 @@ func New(opts ...SDKOption) *SDK { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0.0", - SDKVersion: "1.1.1", - GenVersion: "2.214.1", - UserAgent: "speakeasy-sdk/go 1.1.1 2.214.1 1.0.0 airbyte", + SDKVersion: "1.2.0", + GenVersion: "2.272.7", + UserAgent: "speakeasy-sdk/go 1.2.0 2.272.7 1.0.0 airbyte", }, } for _, opt := range opts { diff --git a/internal/validators/boolvalidators/not_null.go b/internal/validators/boolvalidators/not_null.go new file mode 100644 index 0000000..45e2e97 --- /dev/null +++ b/internal/validators/boolvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package boolvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Bool = BoolNotNullValidator{} + +// BoolNotNullValidator 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 BoolNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v BoolNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v BoolNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v BoolNotNullValidator) ValidateBool(ctx context.Context, req validator.BoolRequest, resp *validator.BoolResponse) { + 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.Bool { + return BoolNotNullValidator{} +} diff --git a/internal/validators/float64validators/not_null.go b/internal/validators/float64validators/not_null.go new file mode 100644 index 0000000..75099c2 --- /dev/null +++ b/internal/validators/float64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package float64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Float64 = Float64NotNullValidator{} + +// Float64NotNullValidator 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 Float64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Float64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Float64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Float64NotNullValidator) ValidateFloat64(ctx context.Context, req validator.Float64Request, resp *validator.Float64Response) { + 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.Float64 { + return Float64NotNullValidator{} +} diff --git a/internal/validators/int64validators/not_null.go b/internal/validators/int64validators/not_null.go new file mode 100644 index 0000000..32192d8 --- /dev/null +++ b/internal/validators/int64validators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package int64validators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Int64 = Int64NotNullValidator{} + +// Int64NotNullValidator 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 Int64NotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v Int64NotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v Int64NotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v Int64NotNullValidator) ValidateInt64(ctx context.Context, req validator.Int64Request, resp *validator.Int64Response) { + 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.Int64 { + return Int64NotNullValidator{} +} diff --git a/internal/validators/listvalidators/not_null.go b/internal/validators/listvalidators/not_null.go new file mode 100644 index 0000000..c7bfa6e --- /dev/null +++ b/internal/validators/listvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package listvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.List = ListNotNullValidator{} + +// ListNotNullValidator 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 ListNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ListNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ListNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ListNotNullValidator) ValidateList(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) { + 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.List { + return ListNotNullValidator{} +} diff --git a/internal/validators/mapvalidators/not_null.go b/internal/validators/mapvalidators/not_null.go new file mode 100644 index 0000000..7d22172 --- /dev/null +++ b/internal/validators/mapvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package mapvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Map = MapNotNullValidator{} + +// MapNotNullValidator 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 MapNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v MapNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v MapNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v MapNotNullValidator) ValidateMap(ctx context.Context, req validator.MapRequest, resp *validator.MapResponse) { + 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.Map { + return MapNotNullValidator{} +} diff --git a/internal/validators/numbervalidators/not_null.go b/internal/validators/numbervalidators/not_null.go new file mode 100644 index 0000000..b085170 --- /dev/null +++ b/internal/validators/numbervalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package numbervalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Number = NumberNotNullValidator{} + +// NumberNotNullValidator 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 NumberNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v NumberNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v NumberNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v NumberNotNullValidator) ValidateNumber(ctx context.Context, req validator.NumberRequest, resp *validator.NumberResponse) { + 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.Number { + return NumberNotNullValidator{} +} diff --git a/internal/validators/objectvalidators/not_null.go b/internal/validators/objectvalidators/not_null.go new file mode 100644 index 0000000..c45ca8d --- /dev/null +++ b/internal/validators/objectvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package objectvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Object = ObjectNotNullValidator{} + +// ObjectNotNullValidator 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 ObjectNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v ObjectNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v ObjectNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v ObjectNotNullValidator) ValidateObject(ctx context.Context, req validator.ObjectRequest, resp *validator.ObjectResponse) { + 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.Object { + return ObjectNotNullValidator{} +} diff --git a/internal/validators/setvalidators/not_null.go b/internal/validators/setvalidators/not_null.go new file mode 100644 index 0000000..23d6c16 --- /dev/null +++ b/internal/validators/setvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package setvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.Set = SetNotNullValidator{} + +// SetNotNullValidator 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 SetNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v SetNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v SetNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v SetNotNullValidator) ValidateSet(ctx context.Context, req validator.SetRequest, resp *validator.SetResponse) { + 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.Set { + return SetNotNullValidator{} +} diff --git a/internal/validators/stringvalidators/not_null.go b/internal/validators/stringvalidators/not_null.go new file mode 100644 index 0000000..f15f8ae --- /dev/null +++ b/internal/validators/stringvalidators/not_null.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +package stringvalidators + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/schema/validator" +) + +var _ validator.String = StringNotNullValidator{} + +// StringNotNullValidator 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 StringNotNullValidator struct{} + +// Description describes the validation in plain text formatting. +func (v StringNotNullValidator) Description(_ context.Context) string { + return "value must be configured" +} + +// MarkdownDescription describes the validation in Markdown formatting. +func (v StringNotNullValidator) MarkdownDescription(ctx context.Context) string { + return v.Description(ctx) +} + +// Validate performs the validation. +func (v StringNotNullValidator) ValidateString(ctx context.Context, req validator.StringRequest, resp *validator.StringResponse) { + 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.String { + return StringNotNullValidator{} +} diff --git a/main.go b/main.go index c3a933c..ccbc09e 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( // Run the docs generation tool, check its repository for more information on how it works and how docs // can be customized. -//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name terraform-provider-airbyte --rendered-provider-name terraform-provider-airbyte var ( // these will be set by the goreleaser configuration