public async Task RemoveAsync(AppInstanceEntity entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } await Client.DeleteAsync(entity, "Self", entity).ConfigureAwait(false); }
/// <summary> /// Retrieve a detailed metric for the app instance. /// </summary> /// <param name="entity">The app instance to retrieve metrics for.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> /// <param name="measurement">The measurement to get.</param> /// <returns></returns> public async Task <MeasurementTimeseriesPart> GetMeasurementTimeseriesAsync(AppInstanceEntity entity, string measurement, CancellationToken cancellationToken = default) { var parameters = new Dictionary <string, object> { ["id"] = entity.Id, ["measurement"] = measurement }; return(await GroupGetAsync <MeasurementTimeseriesPart>("Metric", parameters, cancellationToken)); }
/// <summary> /// Update an existing app instance. /// </summary> /// <param name="entity">The app instance to update.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> /// <returns>A task indicating completion.</returns> public async Task UpdateAsync(AppInstanceEntity entity, CancellationToken cancellationToken = default) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } await Client.PutAsync(entity, "Self", entity, cancellationToken : cancellationToken).ConfigureAwait(false); }
public async Task <AppInstanceEntity> AddAsync(AppInstanceEntity entity, bool runOnExisting = false) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(await Client.PostAsync <AppInstanceEntity, AppInstanceEntity>(entity, "Create", entity, new Dictionary <string, object> { { "runOnExisting", runOnExisting } }).ConfigureAwait(false)); }
/// <summary> /// Add a new app instance. /// </summary> /// <param name="entity">The app instance to add.</param> /// <param name="runOnExisting">If <c>true</c>, events already on the server will be sent to the app. Note that this requires disk buffering and persistent bookmarks /// for the app, which is not recommended for performance reasons.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> /// <returns>The app instance, with server-allocated properties such as <see cref="Entity.Id"/> initialized.</returns> public async Task <AppInstanceEntity> AddAsync(AppInstanceEntity entity, bool runOnExisting = false, CancellationToken cancellationToken = default) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(await GroupCreateAsync <AppInstanceEntity, AppInstanceEntity>(entity, new Dictionary <string, object> { { "runOnExisting", runOnExisting } }, cancellationToken) .ConfigureAwait(false)); }
public bool SaveOrUpdateAppInstance(AppInstance instance, string spHostWebDomain) { try { AppInstanceEntity updateEntity = null; var table = CredentialManager.GetTableStorage(ApplicationConstants.AzureStorage.StorageConnectionString, ApplicationConstants.AzureStorage.TableStorageKey); if (!String.IsNullOrWhiteSpace(instance.InstanceId)) { // Create a retrieve operation that takes a Dbxlnstance entity. var retrieveOperation = TableOperation.Retrieve <AppInstanceEntity>(instance.O365Domain, instance.InstanceId); // Execute the operation. TableResult retrievedResult = table.Execute(retrieveOperation); // Assign the result to a DbxlInstanceEntity object. updateEntity = retrievedResult.Result as AppInstanceEntity; } if (updateEntity == null) { updateEntity = new AppInstanceEntity(Guid.NewGuid().ToString(), spHostWebDomain); } updateEntity.InstanceName = instance.InstanceName; updateEntity.ServiceURL = instance.ServiceURL; if (!String.IsNullOrWhiteSpace(instance.Username)) { updateEntity.Username = CredentialManager.EncryptData(instance.Username); } if (!String.IsNullOrWhiteSpace(instance.Password)) { updateEntity.Password = CredentialManager.EncryptData(instance.Password); } updateEntity.Domain = instance.Domain; // Create the InsertOrReplace TableOperation var tableOperation = TableOperation.InsertOrReplace(updateEntity); // Execute the operation. table.Execute(tableOperation); return(true); } catch { return(false); } }
/// <summary> /// Send the event with id <paramref name="eventId"/> to the app instance <paramref name="entity"/>. /// </summary> /// <param name="entity">The app instance to invoke.</param> /// <param name="eventId">The id of an event to send to the app.</param> /// <param name="settingOverrides">Values for any overridable settings exposed by the app instance.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> allowing the operation to be canceled.</param> /// <returns>A task indicating completion.</returns> public async Task InvokeAsync(AppInstanceEntity entity, string eventId, IReadOnlyDictionary <string, string> settingOverrides, CancellationToken cancellationToken = default) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (eventId == null) { throw new ArgumentNullException(nameof(eventId)); } var postedSettings = settingOverrides ?? new Dictionary <string, string>(); await Client.PostAsync(entity, "Invoke", postedSettings, new Dictionary <string, object> { { "eventId", eventId } }, cancellationToken); }
public async Task UpdateAsync(AppInstanceEntity entity) { await Client.PutAsync(entity, "Self", entity).ConfigureAwait(false); }
public async Task RemoveAsync(AppInstanceEntity entity) { await Client.DeleteAsync(entity, "Self", entity).ConfigureAwait(false); }
public async Task <AppInstanceEntity> AddAsync(AppInstanceEntity entity, bool runOnExisting = false) { return(await Client.PostAsync <AppInstanceEntity, AppInstanceEntity>(entity, "Create", entity, new Dictionary <string, object> { { "runOnExisting", runOnExisting } }).ConfigureAwait(false)); }