@@ -72,6 +72,9 @@ type IResourceNoRefresh interface {
7272 // Example: func (r *ResourceJob) DoUpdate(ctx context.Context, id string, newState *jobs.JobSettings) error
7373 DoUpdate (ctx context.Context , id string , newState any ) error
7474
75+ // [Optional] DoUpdateWithChanges updates the resource with information about changes computed during plan.
76+ DoUpdateWithChanges (ctx context.Context , id string , newState any , changes * deployplan.Changes ) error
77+
7578 // [Optional] DoUpdateWithID performs an update that may result in resource having a new ID
7679 // Example: func (r *ResourceVolume) DoUpdateWithID(ctx, id string, newState *catalog.CreateVolumeRequestContent) (string, error)
7780 DoUpdateWithID (ctx context.Context , id string , newState any ) (string , error )
@@ -104,6 +107,10 @@ type IResourceWithRefresh interface {
104107 // Example: func (r *ResourceSchema) DoUpdate(ctx context.Context, id string, newState *catalog.CreateSchema) (*catalog.SchemaInfo, error)
105108 DoUpdate (ctx context.Context , id string , newState any ) (remoteState any , e error )
106109
110+ // [Optional] DoUpdateWithChanges updates the resource with information about changes computed during plan. Returns remote state.
111+ // Example: func (r *ResourceModelServingEndpoint) DoUpdateWithChanges(ctx context.Context, id string, newState *serving.CreateServingEndpoint, changes *deployplan.Changes) (*serving.ServingEndpointInfo, error)
112+ DoUpdateWithChanges (ctx context.Context , id string , newState any , changes * deployplan.Changes ) (remoteState any , e error )
113+
107114 // Optional: updates that may change ID. Returns new id and remote state when available.
108115 DoUpdateWithID (ctx context.Context , id string , newState any ) (newID string , remoteState any , e error )
109116
@@ -126,11 +133,12 @@ type Adapter struct {
126133 doUpdate * calladapt.BoundCaller
127134
128135 // Optional:
129- doUpdateWithID * calladapt.BoundCaller
130- waitAfterCreate * calladapt.BoundCaller
131- waitAfterUpdate * calladapt.BoundCaller
132- classifyChange * calladapt.BoundCaller
133- doResize * calladapt.BoundCaller
136+ doUpdateWithChanges * calladapt.BoundCaller
137+ doUpdateWithID * calladapt.BoundCaller
138+ waitAfterCreate * calladapt.BoundCaller
139+ waitAfterUpdate * calladapt.BoundCaller
140+ classifyChange * calladapt.BoundCaller
141+ doResize * calladapt.BoundCaller
134142
135143 fieldTriggersLocal map [string ]deployplan.ActionType
136144 fieldTriggersRemote map [string ]deployplan.ActionType
@@ -156,6 +164,7 @@ func NewAdapter(typedNil any, client *databricks.WorkspaceClient) (*Adapter, err
156164 doDelete : nil ,
157165 doCreate : nil ,
158166 doUpdate : nil ,
167+ doUpdateWithChanges : nil ,
159168 doUpdateWithID : nil ,
160169 doResize : nil ,
161170 waitAfterCreate : nil ,
@@ -260,6 +269,11 @@ func (a *Adapter) initMethods(resource any) error {
260269
261270 // Optional methods:
262271
272+ a .doUpdateWithChanges , err = prepareCallFromTwoVariants (resource , "DoUpdateWithChanges" )
273+ if err != nil {
274+ return err
275+ }
276+
263277 a .doUpdateWithID , err = prepareCallFromTwoVariants (resource , "DoUpdateWithID" )
264278 if err != nil {
265279 return err
@@ -345,6 +359,13 @@ func (a *Adapter) validate() error {
345359 validations = append (validations , "DoUpdate remoteState return" , a .doUpdate .OutTypes [0 ], remoteType )
346360 }
347361
362+ if a .doUpdateWithChanges != nil {
363+ validations = append (validations , "DoUpdateWithChanges newState" , a .doUpdateWithChanges .InTypes [2 ], stateType )
364+ if len (a .doUpdateWithChanges .OutTypes ) == 2 {
365+ validations = append (validations , "DoUpdateWithChanges remoteState return" , a .doUpdateWithChanges .OutTypes [0 ], remoteType )
366+ }
367+ }
368+
348369 if a .doResize != nil {
349370 validations = append (validations , "DoResize newState" , a .doResize .InTypes [2 ], stateType )
350371 }
@@ -497,6 +518,32 @@ func (a *Adapter) DoUpdate(ctx context.Context, id string, newState any) (any, e
497518 }
498519}
499520
521+ // HasDoUpdateWithChanges returns true if the resource implements DoUpdateWithChanges method.
522+ func (a * Adapter ) HasDoUpdateWithChanges () bool {
523+ return a .doUpdateWithChanges != nil
524+ }
525+
526+ // DoUpdateWithChanges updates the resource with information about changes computed during plan.
527+ // If the implementation returns remote state, it will be returned as the first value; otherwise it will be nil.
528+ func (a * Adapter ) DoUpdateWithChanges (ctx context.Context , id string , newState any , changes * deployplan.Changes ) (any , error ) {
529+ if a .doUpdateWithChanges == nil {
530+ return nil , errors .New ("internal error: DoUpdateWithChanges not found" )
531+ }
532+
533+ outs , err := a .doUpdateWithChanges .Call (ctx , id , newState , changes )
534+ if err != nil {
535+ return nil , err
536+ }
537+
538+ if len (outs ) == 1 {
539+ // WithRefresh version
540+ return outs [0 ], nil
541+ } else {
542+ // NoRefresh version
543+ return nil , nil
544+ }
545+ }
546+
500547// HasDoUpdateWithID returns true if the resource implements DoUpdateWithID method.
501548func (a * Adapter ) HasDoUpdateWithID () bool {
502549 return a .doUpdateWithID != nil
0 commit comments