1010using System ;
1111using System . Collections . Generic ;
1212using System . IO ;
13- using System . Linq ;
14- using System . Text ;
15- using System . Text . Json ;
1613
1714namespace Microsoft . Azure . Commands . Synapse . Models
1815{
@@ -73,11 +70,7 @@ public PipelineResource CreateOrUpdatePipeline(string pipelineName, string rawJs
7370 PSPipelineResource psPipeline = JsonConvert . DeserializeObject < PSPipelineResource > ( rawJsonContent , Settings ) ;
7471 PipelineResource pipeline = psPipeline . ToSdkObject ( ) ;
7572 var operation = _pipelineClient . StartCreateOrUpdatePipeline ( pipelineName , pipeline ) ;
76- while ( ! operation . HasValue )
77- {
78- operation . UpdateStatus ( ) ;
79- }
80- return operation . Value ;
73+ return operation . Poll ( ) . Value ;
8174 }
8275
8376 public PipelineResource GetPipeline ( string pipelineName )
@@ -92,18 +85,18 @@ public Pageable<PipelineResource> GetPipelinesByWorkspace()
9285
9386 public void DeletePipeline ( string pipelineName )
9487 {
95- _pipelineClient . StartDeletePipeline ( pipelineName ) ;
88+ _pipelineClient . StartDeletePipeline ( pipelineName ) . Poll ( ) ;
9689 }
9790
91+ #endregion
92+
93+ #region pipeline run
94+
9895 public CreateRunResponse CreatePipelineRun ( string pipelineName , string referencePipelineRunId , bool ? isRecovery , string startActivityName , IDictionary < string , object > parameters )
9996 {
10097 return _pipelineClient . CreatePipelineRun ( pipelineName , referencePipelineRunId , isRecovery , startActivityName , parameters ) ;
10198 }
10299
103- #endregion
104-
105- #region pipeline run
106-
107100 public PipelineRun GetPipelineRun ( string runId )
108101 {
109102 return _pipelineRunClient . GetPipelineRun ( runId ) . Value ;
@@ -143,16 +136,12 @@ public LinkedServiceResource CreateOrUpdateLinkedService(string linkedServiceNam
143136 PSLinkedServiceResource psLinkedService = JsonConvert . DeserializeObject < PSLinkedServiceResource > ( rawJsonContent , Settings ) ;
144137 LinkedServiceResource linkedService = psLinkedService . ToSdkObject ( ) ;
145138 var operation = _linkedServiceClient . StartCreateOrUpdateLinkedService ( linkedServiceName , linkedService ) ;
146- while ( ! operation . HasValue )
147- {
148- operation . UpdateStatus ( ) ;
149- }
150- return operation . Value ;
139+ return operation . Poll ( ) . Value ;
151140 }
152141
153142 public void DeleteLinkedService ( string linkedServiceName )
154143 {
155- _linkedServiceClient . StartDeleteLinkedService ( linkedServiceName ) ;
144+ _linkedServiceClient . StartDeleteLinkedService ( linkedServiceName ) . Poll ( ) ;
156145 }
157146
158147 #endregion
@@ -162,16 +151,12 @@ public void DeleteLinkedService(string linkedServiceName)
162151 public NotebookResource CreateOrUpdateNotebook ( string notebookName , NotebookResource notebook )
163152 {
164153 var operation = _notebookClient . StartCreateOrUpdateNotebook ( notebookName , notebook ) ;
165- while ( ! operation . HasValue )
166- {
167- operation . UpdateStatus ( ) ;
168- }
169- return operation . Value ;
154+ return operation . Poll ( ) . Value ;
170155 }
171156
172157 public void DeleteNotebook ( string notebookName )
173158 {
174- _notebookClient . StartDeleteNotebook ( notebookName ) ;
159+ _notebookClient . StartDeleteNotebook ( notebookName ) . Poll ( ) ;
175160 }
176161
177162 public NotebookResource GetNotebook ( string notebookName )
@@ -193,11 +178,7 @@ public TriggerResource CreateOrUpdateTrigger(string triggerName, string rawJsonC
193178 PSTriggerResource pSTrigger = JsonConvert . DeserializeObject < PSTriggerResource > ( rawJsonContent , Settings ) ;
194179 TriggerResource trigger = pSTrigger . ToSdkObject ( ) ;
195180 var operation = _triggerClient . StartCreateOrUpdateTrigger ( triggerName , trigger ) ;
196- while ( ! operation . HasValue )
197- {
198- operation . UpdateStatus ( ) ;
199- }
200- return operation . Value ;
181+ return operation . Poll ( ) . Value ;
201182 }
202183
203184 public TriggerResource GetTrigger ( string triggerName )
@@ -212,37 +193,33 @@ public Pageable<TriggerResource> GetTriggersByWorkspace()
212193
213194 public void DeleteTrigger ( string triggerName )
214195 {
215- _triggerClient . StartDeleteTrigger ( triggerName ) ;
196+ _triggerClient . StartDeleteTrigger ( triggerName ) . Poll ( ) ;
216197 }
217198
218199 public TriggerSubscriptionOperationStatus GetEventSubscriptionStatus ( string triggerName )
219200 {
220201 return _triggerClient . GetEventSubscriptionStatus ( triggerName ) ;
221202 }
222203
223- public TriggerSubscriptionOperationStatus StartSubscribeTriggerToEvents ( string triggerName )
204+ public TriggerSubscriptionOperationStatus SubscribeTriggerToEvents ( string triggerName )
224205 {
225206 var operation = _triggerClient . StartSubscribeTriggerToEvents ( triggerName ) ;
226- while ( ! operation . HasValue )
227- {
228- operation . UpdateStatus ( ) ;
229- }
230- return operation . Value ;
207+ return operation . Poll ( ) . Value ;
231208 }
232209
233- public void StartUnsubscribeTriggerFromEvents ( string triggerName )
210+ public void UnsubscribeTriggerFromEvents ( string triggerName )
234211 {
235- _triggerClient . StartUnsubscribeTriggerFromEvents ( triggerName ) ;
212+ _triggerClient . StartUnsubscribeTriggerFromEvents ( triggerName ) . Poll ( ) ;
236213 }
237214
238- public void StartStartTrigger ( string triggerName )
215+ public void StartTrigger ( string triggerName )
239216 {
240- _triggerClient . StartStartTrigger ( triggerName ) ;
217+ _triggerClient . StartStartTrigger ( triggerName ) . Poll ( ) ;
241218 }
242219
243- public void StartStopTrigger ( string triggerName )
220+ public void StopTrigger ( string triggerName )
244221 {
245- _triggerClient . StartStopTrigger ( triggerName ) ;
222+ _triggerClient . StartStopTrigger ( triggerName ) . Poll ( ) ;
246223 }
247224
248225 public IReadOnlyList < TriggerRun > QueryTriggerRunsByWorkspace ( RunFilterParameters filterParameters )
@@ -259,11 +236,7 @@ public DatasetResource CreateOrUpdateDataset(string datasetName, string rawJsonC
259236 PSDatasetResource pSDatasetResource = JsonConvert . DeserializeObject < PSDatasetResource > ( rawJsonContent , Settings ) ;
260237 DatasetResource dataset = pSDatasetResource . ToSdkObject ( ) ;
261238 var operation = _datasetClient . StartCreateOrUpdateDataset ( datasetName , dataset ) ;
262- while ( ! operation . HasValue )
263- {
264- operation . UpdateStatus ( ) ;
265- }
266- return operation . Value ;
239+ return operation . Poll ( ) . Value ;
267240 }
268241
269242 public DatasetResource GetDataset ( string datasetName )
@@ -278,7 +251,7 @@ public Pageable<DatasetResource> GetDatasetsByWorkspace()
278251
279252 public void DeleteDataset ( string datasetName )
280253 {
281- _datasetClient . StartDeleteDataset ( datasetName ) ;
254+ _datasetClient . StartDeleteDataset ( datasetName ) . Poll ( ) ;
282255 }
283256
284257 #endregion
@@ -290,11 +263,7 @@ public DataFlowResource CreateOrUpdateDataFlow(string dataFlowName, string rawJs
290263 PSDataFlowResource pSDatasetResource = JsonConvert . DeserializeObject < PSDataFlowResource > ( rawJsonContent , Settings ) ;
291264 DataFlowResource dataFlow = pSDatasetResource . ToSdkObject ( ) ;
292265 var operation = _dataFlowClient . StartCreateOrUpdateDataFlow ( dataFlowName , dataFlow ) ;
293- while ( ! operation . HasValue )
294- {
295- operation . UpdateStatus ( ) ;
296- }
297- return operation . Value ;
266+ return operation . Poll ( ) . Value ;
298267 }
299268
300269 public DataFlowResource GetDataFlow ( string dataFlowName )
@@ -309,7 +278,7 @@ public Pageable<DataFlowResource> GetDataFlowsByWorkspace()
309278
310279 public void DeleteDataFlow ( string dataFlowName )
311280 {
312- _dataFlowClient . StartDeleteDataFlow ( dataFlowName ) ;
281+ _dataFlowClient . StartDeleteDataFlow ( dataFlowName ) . Poll ( ) ;
313282 }
314283
315284 #endregion
0 commit comments