/// <summary> /// Modifies the Alarm with the Id provided to the values supplied. Returns /// the modified Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be modified. Must be double URL encoded. /// </param> /// <param name='updatedItem'> /// Item to be updated. All modfied properties will be changed. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AlarmModel> UpdateAsync(this IAlarms operations, string id, UpdateAlarmModel updatedItem, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(id, updatedItem, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public AlarmsTest() { var servicesConfig = new AppConfig { DeviceTelemetryService = new DeviceTelemetryServiceConfig { Alarms = new AlarmsConfig { Database = "database", Collection = "collection", MaxDeleteRetries = 3, }, }, }; this.storageClient = new Mock <IStorageClient>(); this.httpContextAccessor = new Mock <IHttpContextAccessor>(); this.appConfigHelper = new Mock <IAppConfigurationClient>(); this.httpContextAccessor.Setup(t => t.HttpContext.Request.HttpContext.Items).Returns(new Dictionary <object, object>() { { "TenantID", TenantId } }); this.appConfigHelper.Setup(t => t.GetValue($"{TenantInfoKey}:{TenantId}:{TelemetryCollectionKey}")).Returns("collection"); this.logger = new Mock <ILogger <Alarms> >(); this.alarms = new Alarms(servicesConfig, this.storageClient.Object, this.logger.Object, this.httpContextAccessor.Object, this.appConfigHelper.Object); }
/// <summary> /// Creates a new Alarm and returns it. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='newItem'> /// Definition of how the Alarm will be created. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AlarmModel> CreateAsync(this IAlarms operations, NewAlarmModel newItem, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(newItem, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns the TransitionModel property for the Alarm with the Id provided. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm whose TransitionModel property is to be returned. Must be /// double URL encoded. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> RetrieveTransitionModelAsync(this IAlarms operations, string id, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.RetrieveTransitionModelWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Returns all Alarms which fit the filter criteria supplied. All filter /// parameters are optional. Alarms will be ordered and paged as requested. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='name'> /// Return only Alarm whose name contains this value. /// </param> /// <param name='state'> /// Return only Alarm with this State value. Possible values include: /// 'Normal', 'Active', 'Acknowledged', 'Reset', 'Disabled' /// </param> /// <param name='orderBy'> /// Alarm will be returned in this order. TransitionedAtAscending by default. /// Possible values include: 'NameAscending', 'NameDescending' /// </param> /// <param name='take'> /// Number of Alarm that should be returned. 200 by default. /// </param> /// <param name='skip'> /// Number of Alarm that should be skipped before items are returned. 0 by /// default. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <IList <AlarmModel> > RetrieveAsync(this IAlarms operations, string name = default(string), string state = default(string), string orderBy = default(string), int?take = default(int?), int?skip = default(int?), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.RetrieveWithHttpMessagesAsync(name, state, orderBy, take, skip, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Modifies the Id property for the Alarm with the Id provided to the new /// value supplied. Returns the modified Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm whose Id property is to be modified. Must be double URL /// encoded. /// </param> /// <param name='newValue'> /// New Id value. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <string> UpdateIdAsync(this IAlarms operations, string id, string newValue, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateIdWithHttpMessagesAsync(id, newValue, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Executes a manual state change action on the Alarm with the Id provided /// (Alarm must have an Unrestricted TransitionModel). The result will /// generate a new AlarmEvent based on the information contained in the /// newEvent parameter. /// Restrictions apply based on the TransitionModel of the Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be Acknowledged. Must be double URL encoded. /// </param> /// <param name='newEvent'> /// Information to describe the generated AlarmEvent. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AlarmModel> ChangeStateAsync(this IAlarms operations, string id, AlarmEventStateChangeInfo newEvent, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.ChangeStateWithHttpMessagesAsync(id, newEvent, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Deletes the Alarm with the Id provided. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be deleted. Must be double URL encoded. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> DeleteAsync(this IAlarms operations, string id, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.DeleteWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public AlarmsController( IAlarms alarmService, ILogger logger) { this.alarmService = alarmService; this.log = logger; }
/// <summary> /// Get alarm /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// The id of the alarm /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <object> GetAsyncByidAsync(this IAlarms operations, int id, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetAsyncByidWithHttpMessagesAsync(id, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public Rules( IStorageAdapterClient storage, ILogger logger, IAlarms alarms) { this.storage = storage; this.log = logger; this.alarms = alarms; }
public AlarmsByRuleController( IAlarms alarmService, IRules ruleService, ILogger logger) { this.alarmService = alarmService; this.ruleService = ruleService; this.log = logger; }
public AlarmsController( IAlarms alarmService, ILogger <AlarmsController> logger, AppConfig appConfig) { this.alarmService = alarmService; this.logger = logger; this.appConfig = appConfig; }
public AlarmsTest() { var servicesConfig = new ServicesConfig { AlarmsConfig = new AlarmsConfig("database", "collection", 3) }; this.storageClient = new Mock <IStorageClient>(); this.logger = new Mock <ILogger>(); this.alarms = new Alarms(servicesConfig, this.storageClient.Object, this.logger.Object); }
public Rules( IStorageAdapterClient storage, ILogger logger, IAlarms alarms, IDiagnosticsClient diagnosticsClient) { this.storage = storage; this.log = logger; this.alarms = alarms; this.diagnosticsClient = diagnosticsClient; }
public AlarmsByRuleController( IAlarms alarmService, IRules ruleService, ILogger <AlarmsByRuleController> logger, AppConfig appConfig) { this.alarmService = alarmService; this.ruleService = ruleService; this.logger = logger; this.appConfig = appConfig; }
public Messages( ILogger logger, IServicesConfig config, IDeviceMessageParser messageParser, IAlarms alarms, IDocumentWriter documentWriter) { this.logger = logger; this.messageParser = messageParser; this.alarms = alarms; this.documentWriter = documentWriter; this.documentWriter.OpenAsync(config.MessagesStorageServiceConfig).Wait(); }
/// <summary> /// Updates an Alarm /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// The id of the alarm /// </param> /// <param name='alarm'> /// The changes to apply /// </param> public static object PatchAsyncByidalarm(this IAlarms operations, int id, EditAlarmDto alarm) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IAlarms)s).PatchAsyncByidalarmAsync(id, alarm), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Get alarms /// </summary> /// <remarks> /// It is possible to filter by state /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='orderby'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// ascending order by the supplied property.</p><p>Valid values /// are: <strong>Created</strong> /// (default).</p><p>Note: <strong>orderby</strong> /// and <strong>orderbydesc</strong> are mutually /// exclusive.</p> /// </param> /// <param name='orderbydesc'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// descending order by the supplied property.</p><p>Valid values /// are: <strong>Created</strong> /// (default).</p><p>Note: <strong>orderby</strong> /// and <strong>orderbydesc</strong> are mutually /// exclusive.</p> /// </param> /// <param name='unitAccountAccountId'> /// <p><a href="#queryoptions">Filters</a> the result by /// Unit.Account.AccountId using the supplied operation and /// value.</p><p>Valid operations are: /// <strong>eq(int)</strong></p> /// </param> /// <param name='state'> /// <p><a href="#queryoptions">Filters</a> the result by /// State using the supplied operation and value.</p><p>Valid /// operations are: /// <strong>eq(alarmstate)</strong></p><p>state = /// ['Unresolved', 'Reject', 'Solved', 'Reset', 'AutoResolved']</p> /// </param> /// <param name='top'> /// <a href="#queryoptions">Query paging</a> Returns the maximum /// number of entities. Default and max value is 10000 /// </param> /// <param name='skip'> /// <a href="#queryoptions">Query paging</a> Skips this number of /// entities /// </param> public static object GetCollectionAsyncByqueryOptions(this IAlarms operations, string orderby = "Created", string orderbydesc = default(string), string unitAccountAccountId = default(string), string state = default(string), int?top = 10000, int?skip = default(int?)) { return(System.Threading.Tasks.Task.Factory.StartNew(s => ((IAlarms)s).GetCollectionAsyncByqueryOptionsAsync(orderby, orderbydesc, unitAccountAccountId, state, top, skip), operations, System.Threading.CancellationToken.None, System.Threading.Tasks.TaskCreationOptions.None, System.Threading.Tasks.TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Deletes the Alarm with the Id provided. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be deleted. Must be double URL encoded. /// </param> public static object Delete(this IAlarms operations, string id) { return(Task.Factory.StartNew(s => ((IAlarms)s).DeleteAsync(id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Executes a manual state change action on the Alarm with the Id provided /// (Alarm must have an Unrestricted TransitionModel). The result will /// generate a new AlarmEvent based on the information contained in the /// newEvent parameter. /// Restrictions apply based on the TransitionModel of the Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be Acknowledged. Must be double URL encoded. /// </param> /// <param name='newEvent'> /// Information to describe the generated AlarmEvent. /// </param> public static AlarmModel ChangeState(this IAlarms operations, string id, AlarmEventStateChangeInfo newEvent) { return(Task.Factory.StartNew(s => ((IAlarms)s).ChangeStateAsync(id, newEvent), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Returns all Alarms which fit the filter criteria supplied. All filter /// parameters are optional. Alarms will be ordered and paged as requested. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='name'> /// Return only Alarm whose name contains this value. /// </param> /// <param name='state'> /// Return only Alarm with this State value. Possible values include: /// 'Normal', 'Active', 'Acknowledged', 'Reset', 'Disabled' /// </param> /// <param name='orderBy'> /// Alarm will be returned in this order. TransitionedAtAscending by default. /// Possible values include: 'NameAscending', 'NameDescending' /// </param> /// <param name='take'> /// Number of Alarm that should be returned. 200 by default. /// </param> /// <param name='skip'> /// Number of Alarm that should be skipped before items are returned. 0 by /// default. /// </param> public static IList <AlarmModel> Retrieve(this IAlarms operations, string name = default(string), string state = default(string), string orderBy = default(string), int?take = default(int?), int?skip = default(int?)) { return(Task.Factory.StartNew(s => ((IAlarms)s).RetrieveAsync(name, state, orderBy, take, skip), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Returns the parent Container for the Alarm with the Id provided. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm whose parent Container is to be returned. Must be double /// URL encoded. /// </param> public static ContainerModel RetrieveParent(this IAlarms operations, string id) { return(Task.Factory.StartNew(s => ((IAlarms)s).RetrieveParentAsync(id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Get alarms from the users subscriptions /// </summary> /// <remarks> /// Retrieves unresolved alarms for all units the authenticated user is /// subscribed to. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='orderby'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// ascending order by the supplied property.</p><p>Valid values /// are: <strong>Created</strong> /// (default).</p><p>Note: <strong>orderby</strong> /// and <strong>orderbydesc</strong> are mutually /// exclusive.</p> /// </param> /// <param name='orderbydesc'> /// <p><a href='#queryoptions'>Sorts</a> the result in /// descending order by the supplied property.</p><p>Valid values /// are: <strong>Created</strong> /// (default).</p><p>Note: <strong>orderby</strong> /// and <strong>orderbydesc</strong> are mutually /// exclusive.</p> /// </param> /// <param name='unitAccountAccountId'> /// <p><a href="#queryoptions">Filters</a> the result by /// Unit.Account.AccountId using the supplied operation and /// value.</p><p>Valid operations are: /// <strong>eq(int)</strong></p> /// </param> /// <param name='created'> /// <p><a href="#queryoptions">Filters</a> the result by /// Created using the supplied operation and value.</p><p>Valid /// operations are: <strong>eq(datetime)</strong>, /// <strong>ge(datetime)</strong>, /// <strong>gt(datetime)</strong>, /// <strong>le(datetime)</strong>, /// <strong>lt(datetime)</strong></p> /// </param> /// <param name='top'> /// <a href="#queryoptions">Query paging</a> Returns the maximum /// number of entities. Default and max value is 10000 /// </param> /// <param name='skip'> /// <a href="#queryoptions">Query paging</a> Skips this number of /// entities /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <object> GetFeedAsyncByqueryOptionsAsync(this IAlarms operations, string orderby = "Created", string orderbydesc = default(string), string unitAccountAccountId = default(string), string created = default(string), int?top = 10000, int?skip = default(int?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.GetFeedAsyncByqueryOptionsWithHttpMessagesAsync(orderby, orderbydesc, unitAccountAccountId, created, top, skip, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Modifies the Alarm with the Id provided to the values supplied. Returns /// the modified Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm to be modified. Must be double URL encoded. /// </param> /// <param name='updatedItem'> /// Item to be updated. All modfied properties will be changed. /// </param> public static AlarmModel Update(this IAlarms operations, string id, UpdateAlarmModel updatedItem) { return(Task.Factory.StartNew(s => ((IAlarms)s).UpdateAsync(id, updatedItem), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Modifies the Id property for the Alarm with the Id provided to the new /// value supplied. Returns the modified Alarm. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// Id of the Alarm whose Id property is to be modified. Must be double URL /// encoded. /// </param> /// <param name='newValue'> /// New Id value. /// </param> public static string UpdateId(this IAlarms operations, string id, string newValue) { return(Task.Factory.StartNew(s => ((IAlarms)s).UpdateIdAsync(id, newValue), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public FuelMessaging(IAlarms alarms) { _alarms = alarms; }