| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.Batch |
| | 5 | | { |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using System.Threading; |
| | 8 | | using System.Threading.Tasks; |
| | 9 | | using Microsoft.Rest.Azure; |
| | 10 | | using Models = Microsoft.Azure.Batch.Protocol.Models; |
| | 11 | |
|
| | 12 | | /// <summary> |
| | 13 | | /// A job schedule that allows recurring jobs by specifying when to run jobs and a specification used to create each |
| | 14 | | /// </summary> |
| | 15 | | public partial class CloudJobSchedule : IRefreshable |
| | 16 | | { |
| | 17 | |
|
| | 18 | | #region // CloudJobSchedule |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Commits this <see cref="CloudJobSchedule" /> to the Azure Batch service. |
| | 22 | | /// </summary> |
| | 23 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 24 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 25 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 26 | | /// <remarks> |
| | 27 | | /// <para>The commit operation runs asynchronously.</para> |
| | 28 | | /// </remarks> |
| | 29 | | public async System.Threading.Tasks.Task CommitAsync( |
| | 30 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| | 31 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 32 | | { |
| | 33 | | // after this no prop access is allowed |
| 3 | 34 | | this.propertyContainer.IsReadOnly = true; |
| | 35 | |
|
| | 36 | | // craft the behavior manager for this call |
| 3 | 37 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 38 | |
|
| | 39 | | // fetch props with admin rights so we can make calls, etc. |
| | 40 | |
|
| 3 | 41 | | if (BindingState.Unbound == this.propertyContainer.BindingState) |
| | 42 | | { |
| | 43 | | // take all property changes and create a job schedule |
| 110 | 44 | | Models.JobScheduleAddParameter protoJobSchedule = this.GetTransportObject<Models.JobScheduleAddParameter |
| | 45 | |
|
| 110 | 46 | | System.Threading.Tasks.Task<AzureOperationHeaderResponse<Models.JobScheduleAddHeaders>> asyncTask = |
| 110 | 47 | | this.parentBatchClient.ProtocolLayer.AddJobSchedule(protoJobSchedule, bhMgr, cancellationToken); |
| 107 | 48 | |
|
| 110 | 49 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 107 | 50 | | } |
| 107 | 51 | | else |
| 107 | 52 | | { |
| 107 | 53 | | Models.JobSpecification jobSpecification = UtilitiesInternal.CreateObjectWithNullCheck(this.JobSpecifica |
| 107 | 54 | | Models.Schedule schedule = UtilitiesInternal.CreateObjectWithNullCheck(this.Schedule, o => o.GetTranspor |
| 107 | 55 | | Models.MetadataItem[] metadata = UtilitiesInternal.ConvertToProtocolArray(this.Metadata); |
| 107 | 56 | |
|
| 107 | 57 | | System.Threading.Tasks.Task<AzureOperationHeaderResponse<Models.JobScheduleUpdateHeaders>> asyncJobSched |
| 107 | 58 | | this.parentBatchClient.ProtocolLayer.UpdateJobSchedule( |
| 107 | 59 | | this.Id, |
| 107 | 60 | | jobSpecification, |
| 107 | 61 | | metadata, |
| 0 | 62 | | schedule, |
| 1012 | 63 | | bhMgr, |
| 0 | 64 | | cancellationToken); |
| 1012 | 65 | |
|
| 1012 | 66 | | await asyncJobScheduleUpdate.ConfigureAwait(continueOnCapturedContext: false); |
| 1012 | 67 | | } |
| 1015 | 68 | | } |
| 1012 | 69 | |
|
| 1012 | 70 | | /// <summary> |
| 1012 | 71 | | /// Commits this <see cref="CloudJobSchedule" /> to the Azure Batch service. |
| 1012 | 72 | | /// </summary> |
| 1012 | 73 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| 1012 | 74 | | /// <remarks> |
| 1012 | 75 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="CommitAsync"/>.</para> |
| 1012 | 76 | | /// </remarks> |
| 1012 | 77 | | public void Commit(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| 1511 | 78 | | { |
| 1014 | 79 | | Task asyncTask = CommitAsync(additionalBehaviors); |
| 1014 | 80 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 1014 | 81 | | } |
| 1012 | 82 | |
|
| 1012 | 83 | | /// <summary> |
| 1012 | 84 | | /// Commits all pending changes to this <see cref="CloudJobSchedule" /> to the Azure Batch service. |
| 1012 | 85 | | /// </summary> |
| 1498 | 86 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| 1012 | 87 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| 1012 | 88 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| 1012 | 89 | | /// <remarks> |
| 1012 | 90 | | /// <para> |
| 1012 | 91 | | /// Updates an existing <see cref="CloudJobSchedule"/> on the Batch service by replacing its properties with the |
| 1012 | 92 | | /// Unchanged properties are ignored. |
| 1012 | 93 | | /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refr |
| 1012 | 94 | | /// or <see cref="JobScheduleOperations.ListJobSchedules"/>) are applied. |
| 1012 | 95 | | /// Properties which are explicitly set to null will cause an exception because the Batch service does not suppo |
| 1012 | 96 | | /// If you need to set a property to null, use <see cref="Commit"/>. |
| 1012 | 97 | | /// </para> |
| 1012 | 98 | | /// <para>This operation runs asynchronously.</para> |
| 1012 | 99 | | /// </remarks> |
| 1012 | 100 | | public async System.Threading.Tasks.Task CommitChangesAsync( |
| 1012 | 101 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| 1012 | 102 | | CancellationToken cancellationToken = default(CancellationToken)) |
| 1012 | 103 | | { |
| 1019 | 104 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| 1012 | 105 | |
|
| 1529 | 106 | | // after this no prop access is allowed |
| 1018 | 107 | | this.propertyContainer.IsReadOnly = true; |
| 1012 | 108 | |
|
| 1012 | 109 | | // craft the bahavior manager for this call |
| 1018 | 110 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| 1012 | 111 | |
|
| 1018 | 112 | | Models.JobSpecification jobSpecification = this.propertyContainer.JobSpecificationProperty.GetTransportObjec |
| 1017 | 113 | | Models.Schedule schedule = this.propertyContainer.ScheduleProperty.GetTransportObjectIfChanged<Schedule, Mod |
| 1017 | 114 | | Models.MetadataItem[] metadata = this.propertyContainer.MetadataProperty.GetTransportObjectIfChanged<Metadat |
| 1012 | 115 | |
|
| 1017 | 116 | | System.Threading.Tasks.Task asyncJobScheduleUpdate = |
| 1017 | 117 | | this.parentBatchClient.ProtocolLayer.PatchJobSchedule( |
| 1526 | 118 | | this.Id, |
| 1017 | 119 | | jobSpecification, |
| 1017 | 120 | | metadata, |
| 1017 | 121 | | schedule, |
| 1017 | 122 | | bhMgr, |
| 1017 | 123 | | cancellationToken); |
| 1012 | 124 | |
|
| 1017 | 125 | | await asyncJobScheduleUpdate.ConfigureAwait(continueOnCapturedContext: false); |
| 5 | 126 | | } |
| | 127 | |
|
| | 128 | | /// <summary> |
| | 129 | | /// Commits all pending changes to this <see cref="CloudJobSchedule" /> to the Azure Batch service. |
| | 130 | | /// </summary> |
| | 131 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 132 | | /// <remarks> |
| | 133 | | /// <para> |
| | 134 | | /// Updates an existing <see cref="CloudJobSchedule"/> on the Batch service by replacing its properties with the |
| | 135 | | /// Unchanged properties are ignored. |
| | 136 | | /// All changes since the last time this entity was retrieved from the Batch service (either via <see cref="Refr |
| | 137 | | /// or <see cref="JobScheduleOperations.ListJobSchedules"/>) are applied. |
| | 138 | | /// Properties which are explicitly set to null will cause an exception because the Batch service does not suppo |
| 107 | 139 | | /// If you need to set a property to null, use <see cref="Commit"/>. |
| 107 | 140 | | /// </para> |
| 107 | 141 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="CommitChangesAsync"/>.</pa |
| | 142 | | /// </remarks> |
| 107 | 143 | | public void CommitChanges(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| 107 | 144 | | { |
| 114 | 145 | | Task asyncTask = this.CommitChangesAsync(additionalBehaviors); |
| 114 | 146 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 5 | 147 | | } |
| 1010 | 148 | |
|
| 1010 | 149 | |
|
| 1010 | 150 | | /// <summary> |
| 1010 | 151 | | /// Enables this <see cref="CloudJobSchedule" />, allowing jobs to be created according to the <see cref="Schedu |
| | 152 | | /// </summary> |
| 1010 | 153 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| 1010 | 154 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| 1010 | 155 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| 1010 | 156 | | /// <remarks> |
| | 157 | | /// <para>The enable operation runs asynchronously.</para> |
| | 158 | | /// </remarks> |
| | 159 | | public System.Threading.Tasks.Task EnableAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, Canc |
| | 160 | | { |
| | 161 | | // throw if if this object is unbound |
| 0 | 162 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 163 | |
|
| | 164 | | // craft the behavior manager for this call |
| 0 | 165 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 166 | |
|
| | 167 | | // start call |
| 0 | 168 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.EnableJobSchedule(this.Id, bhMg |
| | 169 | |
|
| 1193 | 170 | | return asyncTask; |
| | 171 | | } |
| | 172 | |
|
| | 173 | | /// <summary> |
| | 174 | | /// Enables this <see cref="CloudJobSchedule" />, allowing jobs to be created according to the <see cref="Schedu |
| | 175 | | /// </summary> |
| | 176 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 177 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 178 | | /// <remarks> |
| | 179 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="EnableAsync"/>.</para> |
| | 180 | | /// </remarks> |
| 1002 | 181 | | public void Enable(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 182 | | { |
| 0 | 183 | | Task asyncTask = EnableAsync(additionalBehaviors); |
| 0 | 184 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 185 | | } |
| | 186 | |
|
| | 187 | | /// <summary> |
| | 188 | | /// Disables this <see cref="CloudJobSchedule" />. Disabled schedules do not create new jobs, but may be re-ena |
| 1207 | 189 | | /// </summary> |
| 107 | 190 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 191 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 192 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 193 | | /// <remarks> |
| | 194 | | /// <para>The disable operation runs asynchronously.</para> |
| | 195 | | /// <para>To re-enable the schedule, call <see cref="EnableAsync"/>.</para> |
| | 196 | | /// </remarks> |
| | 197 | | public System.Threading.Tasks.Task DisableAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null, Can |
| 1001 | 198 | | { |
| | 199 | | // throw if if this object is unbound |
| 0 | 200 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 201 | |
|
| | 202 | | // craft the behavior manager for this call |
| 0 | 203 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 204 | |
|
| | 205 | | // start call |
| 1001 | 206 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.DisableJobSchedule(this.Id, bhM |
| | 207 | |
|
| 0 | 208 | | return asyncTask; |
| | 209 | | } |
| | 210 | |
|
| | 211 | | /// <summary> |
| | 212 | | /// Disables this <see cref="CloudJobSchedule" />. Disabled schedules do not create new jobs, but may be re-ena |
| | 213 | | /// </summary> |
| 1221 | 214 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| 109 | 215 | | /// <remarks> |
| | 216 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="DisableAsync"/>.</para> |
| | 217 | | /// <para>To re-enable the schedule, call <see cref="Enable"/>.</para> |
| | 218 | | /// </remarks> |
| | 219 | | public void Disable(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 220 | | { |
| 0 | 221 | | Task asyncTask = DisableAsync(additionalBehaviors); |
| 0 | 222 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 223 | | } |
| 1221 | 224 | |
|
| 99 | 225 | | /// <summary> |
| | 226 | | /// Deletes this <see cref="CloudJobSchedule" />. |
| | 227 | | /// </summary> |
| | 228 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 229 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 230 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 231 | | /// <remarks> |
| | 232 | | /// <para>The delete operation requests that the job schedule be deleted. The request puts the schedule in the |
| 1001 | 233 | | /// The Batch service will delete any existing jobs and tasks under the schedule, including any active job, and |
| | 234 | | /// <para>The delete operation runs asynchronously.</para> |
| | 235 | | /// </remarks> |
| | 236 | | public async System.Threading.Tasks.Task DeleteAsync(IEnumerable<BatchClientBehavior> additionalBehaviors = null |
| | 237 | | { |
| | 238 | | // throw if if this object is unbound |
| 0 | 239 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 240 | |
|
| 1307 | 241 | | // craft the behavior manager for this call |
| 0 | 242 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 243 | |
|
| 63 | 244 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.DeleteJobSchedule(this.Id, bhMg |
| 57 | 245 | |
|
| 0 | 246 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 247 | | } |
| | 248 | |
|
| | 249 | | /// <summary> |
| | 250 | | /// Deletes this <see cref="CloudJobSchedule" />. |
| | 251 | | /// </summary> |
| | 252 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 253 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 254 | | /// <remarks> |
| | 255 | | /// <para>The delete operation requests that the job schedule be deleted. The request puts the schedule in the |
| | 256 | | /// The Batch service will delete any existing jobs and tasks under the schedule, including any active job, and |
| 1001 | 257 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="DeleteAsync"/>.</para> |
| | 258 | | /// </remarks> |
| | 259 | | public void Delete(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 260 | | { |
| 0 | 261 | | Task asyncTask = DeleteAsync(additionalBehaviors); |
| 0 | 262 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 0 | 263 | | } |
| | 264 | |
|
| | 265 | | /// <summary> |
| | 266 | | /// Terminates this <see cref="CloudJobSchedule" />. Terminated schedules remain in the system but do not creat |
| | 267 | | /// </summary> |
| | 268 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| 1001 | 269 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 270 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 271 | | /// <remarks> |
| | 272 | | /// <para>The terminate operation requests that the job schedule be terminated. The request puts the schedule i |
| | 273 | | /// The Batch service will wait for any active job to terminate, and perform the actual job schedule termination |
| | 274 | | /// <para>The terminate operation runs asynchronously.</para> |
| | 275 | | /// </remarks> |
| | 276 | | public async System.Threading.Tasks.Task TerminateAsync( |
| 1206 | 277 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| 95 | 278 | | CancellationToken cancellationToken = default(CancellationToken)) |
| | 279 | | { |
| | 280 | | // throw if if this object is unbound |
| 0 | 281 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 282 | |
|
| | 283 | | // craft the behavior manager for this call |
| 0 | 284 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 285 | |
|
| 1001 | 286 | | System.Threading.Tasks.Task asyncTask = this.parentBatchClient.ProtocolLayer.TerminateJobSchedule(this.Id, b |
| | 287 | |
|
| 0 | 288 | | await asyncTask.ConfigureAwait(continueOnCapturedContext: false); |
| 0 | 289 | | } |
| | 290 | |
|
| | 291 | | /// <summary> |
| | 292 | | /// Terminates this <see cref="CloudJobSchedule" />. Terminated schedules remain in the system but do not creat |
| | 293 | | /// </summary> |
| 1001 | 294 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 295 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> that represents the asynchronous operation.</returns> |
| | 296 | | /// <remarks> |
| | 297 | | /// <para>The terminate operation requests that the job schedule be terminated. The request puts the schedule i |
| | 298 | | /// The Batch service will wait for any active job to terminate, and perform the actual job schedule termination |
| | 299 | | /// <para>This is a blocking operation. For a non-blocking equivalent, see <see cref="TerminateAsync"/>.</para> |
| | 300 | | /// </remarks> |
| | 301 | | public void Terminate(IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 302 | | { |
| 0 | 303 | | Task asyncTask = TerminateAsync(additionalBehaviors); |
| | 304 | | { |
| 0 | 305 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| | 306 | | } |
| 0 | 307 | | } |
| 1001 | 308 | |
|
| | 309 | | /// <summary> |
| | 310 | | /// Enumerates the <see cref="CloudJob">jobs</see> created under this <see cref="CloudJobSchedule"/>. |
| | 311 | | /// </summary> |
| | 312 | | /// <param name="detailLevel">A <see cref="DetailLevel"/> used for filtering the list and for controlling which |
| | 313 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 314 | | /// <returns>An <see cref="IPagedEnumerable{CloudJob}"/> that can be used to enumerate jobs asynchronously or sy |
| | 315 | | /// <remarks>This method returns immediately; the jobs are retrieved from the Batch service only when the collec |
| 1001 | 316 | | /// Retrieval is non-atomic; jobs are retrieved in pages during enumeration of the collection.</remarks> |
| | 317 | | public IPagedEnumerable<CloudJob> ListJobs(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> addi |
| | 318 | | { |
| | 319 | | // throw if if this object is unbound |
| 0 | 320 | | UtilitiesInternal.ThrowOnUnbound(this.propertyContainer.BindingState); |
| | 321 | |
|
| | 322 | | // craft the behavior manager for this call |
| 0 | 323 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors); |
| | 324 | |
|
| 0 | 325 | | IPagedEnumerable<CloudJob> jobs = this.parentBatchClient.JobScheduleOperations.ListJobsImpl(this.Id, bhMgr, |
| | 326 | |
|
| 0 | 327 | | return jobs; |
| | 328 | | } |
| | 329 | |
|
| 0 | 330 | | #endregion // CloudJobSchedule |
| 2 | 331 | |
|
| | 332 | |
|
| | 333 | | #region IRefreshable |
| | 334 | |
|
| | 335 | | /// <summary> |
| | 336 | | /// Refreshes the current <see cref="CloudJobSchedule"/>. |
| | 337 | | /// </summary> |
| | 338 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id |
| | 339 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 340 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynch |
| | 341 | | /// <returns>A <see cref="System.Threading.Tasks.Task"/> representing the asynchronous refresh operation.</retur |
| | 342 | | public async System.Threading.Tasks.Task RefreshAsync( |
| 103 | 343 | | DetailLevel detailLevel = null, |
| 103 | 344 | | IEnumerable<BatchClientBehavior> additionalBehaviors = null, |
| 103 | 345 | | CancellationToken cancellationToken = default(CancellationToken)) |
| 103 | 346 | | { |
| 148 | 347 | | // craft the behavior manager for this call |
| 106 | 348 | | BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors, detailLevel); |
| 149 | 349 | |
|
| 103 | 350 | | // start call |
| 3 | 351 | | System.Threading.Tasks.Task<AzureOperationResponse<Models.CloudJobSchedule, Models.JobScheduleGetHeaders>> a |
| 106 | 352 | | this.parentBatchClient.ProtocolLayer.GetJobSchedule(this.Id, bhMgr, cancellationToken); |
| | 353 | |
|
| 3 | 354 | | AzureOperationResponse<Models.CloudJobSchedule, Models.JobScheduleGetHeaders> response = await asyncTask.Con |
| | 355 | |
|
| | 356 | | // get job schedule from response |
| 2 | 357 | | Models.CloudJobSchedule newProtocolJobSchedule = response.Body; |
| | 358 | |
|
| 2 | 359 | | this.propertyContainer = new PropertyContainer(newProtocolJobSchedule); |
| 2 | 360 | | } |
| | 361 | |
|
| | 362 | | /// <summary> |
| | 363 | | /// Refreshes the current <see cref="CloudJobSchedule"/>. |
| | 364 | | /// </summary> |
| | 365 | | /// <param name="detailLevel">The detail level for the refresh. If a detail level which omits the <see cref="Id |
| | 366 | | /// <param name="additionalBehaviors">A collection of <see cref="BatchClientBehavior"/> instances that are appli |
| | 367 | | public void Refresh(DetailLevel detailLevel = null, IEnumerable<BatchClientBehavior> additionalBehaviors = null) |
| | 368 | | { |
| 1 | 369 | | Task asyncTask = RefreshAsync(detailLevel, additionalBehaviors); |
| 1 | 370 | | asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors); |
| 1 | 371 | | } |
| | 372 | |
|
| | 373 | | #endregion IRefreshable |
| | 374 | |
|
| | 375 | | } |
| | 376 | | } |