@@ -12,7 +12,7 @@ import (
1212
1313// ListInstance will return instances in environment.
1414func (c * client ) ListInstance (ctx context.Context , find * api.InstanceFindMessage ) (* api.ListInstanceMessage , error ) {
15- req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/environments/%s/instances?showDeleted=%v" , c .HostURL , find .EnvironmentID , find .ShowDeleted ), nil )
15+ req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/ environments/%s/instances?showDeleted=%v" , c .url , c . version , find .EnvironmentID , find .ShowDeleted ), nil )
1616 if err != nil {
1717 return nil , err
1818 }
@@ -33,7 +33,7 @@ func (c *client) ListInstance(ctx context.Context, find *api.InstanceFindMessage
3333
3434// GetInstance gets the instance by id.
3535func (c * client ) GetInstance (ctx context.Context , find * api.InstanceFindMessage ) (* api.InstanceMessage , error ) {
36- req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/environments/%s/instances/%s" , c .HostURL , find .EnvironmentID , find .InstanceID ), nil )
36+ req , err := http .NewRequestWithContext (ctx , "GET" , fmt .Sprintf ("%s/%s/ environments/%s/instances/%s" , c .url , c . version , find .EnvironmentID , find .InstanceID ), nil )
3737 if err != nil {
3838 return nil , err
3939 }
@@ -59,7 +59,7 @@ func (c *client) CreateInstance(ctx context.Context, environmentID, instanceID s
5959 return nil , err
6060 }
6161
62- req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/environments/%s/instances?instanceId=%s" , c .HostURL , environmentID , instanceID ), strings .NewReader (string (payload )))
62+ req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/%s/ environments/%s/instances?instanceId=%s" , c .url , c . version , environmentID , instanceID ), strings .NewReader (string (payload )))
6363
6464 if err != nil {
6565 return nil , err
@@ -97,7 +97,7 @@ func (c *client) UpdateInstance(ctx context.Context, environmentID, instanceID s
9797 paths = append (paths , "instance.data_sources" )
9898 }
9999
100- req , err := http .NewRequestWithContext (ctx , "PATCH" , fmt .Sprintf ("%s/environments/%s/instances/%s?update_mask=%s" , c .HostURL , environmentID , instanceID , strings .Join (paths , "," )), strings .NewReader (string (payload )))
100+ req , err := http .NewRequestWithContext (ctx , "PATCH" , fmt .Sprintf ("%s/%s/ environments/%s/instances/%s?update_mask=%s" , c .url , c . version , environmentID , instanceID , strings .Join (paths , "," )), strings .NewReader (string (payload )))
101101
102102 if err != nil {
103103 return nil , err
@@ -119,7 +119,7 @@ func (c *client) UpdateInstance(ctx context.Context, environmentID, instanceID s
119119
120120// DeleteInstance deletes the instance.
121121func (c * client ) DeleteInstance (ctx context.Context , environmentID , instanceID string ) error {
122- req , err := http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/environments/%s/instances/%s" , c .HostURL , environmentID , instanceID ), nil )
122+ req , err := http .NewRequestWithContext (ctx , "DELETE" , fmt .Sprintf ("%s/%s/ environments/%s/instances/%s" , c .url , c . version , environmentID , instanceID ), nil )
123123 if err != nil {
124124 return err
125125 }
@@ -132,7 +132,7 @@ func (c *client) DeleteInstance(ctx context.Context, environmentID, instanceID s
132132
133133// UndeleteInstance undeletes the instance.
134134func (c * client ) UndeleteInstance (ctx context.Context , environmentID , instanceID string ) (* api.InstanceMessage , error ) {
135- req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/environments/%s/instances/%s:undelete" , c .HostURL , environmentID , instanceID ), nil )
135+ req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/%s/ environments/%s/instances/%s:undelete" , c .url , c . version , environmentID , instanceID ), nil )
136136 if err != nil {
137137 return nil , err
138138 }
@@ -150,3 +150,19 @@ func (c *client) UndeleteInstance(ctx context.Context, environmentID, instanceID
150150
151151 return & res , nil
152152}
153+
154+ // SyncInstanceSchema will trigger the schema sync for an instance.
155+ func (c * client ) SyncInstanceSchema (ctx context.Context , instanceUID string ) error {
156+ payload := fmt .Sprintf (`{"data":{"type":"sqlSyncSchema","attributes":{"instanceId":%s}}}` , instanceUID )
157+ req , err := http .NewRequestWithContext (ctx , "POST" , fmt .Sprintf ("%s/api/sql/sync-schema" , c .url ), strings .NewReader (string (payload )))
158+
159+ if err != nil {
160+ return err
161+ }
162+
163+ if _ , err := c .doRequest (req ); err != nil {
164+ return err
165+ }
166+
167+ return nil
168+ }
0 commit comments