Beispiel #1
0
 /// <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);
        }
Beispiel #3
0
 /// <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);
     }
 }
Beispiel #4
0
 /// <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);
     }
 }
Beispiel #5
0
 /// <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);
     }
 }
Beispiel #6
0
 /// <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);
     }
 }
Beispiel #7
0
 /// <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);
     }
 }
Beispiel #8
0
 /// <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);
     }
 }
Beispiel #11
0
 public Rules(
     IStorageAdapterClient storage,
     ILogger logger,
     IAlarms alarms)
 {
     this.storage = storage;
     this.log     = logger;
     this.alarms  = alarms;
 }
Beispiel #12
0
 public AlarmsByRuleController(
     IAlarms alarmService,
     IRules ruleService,
     ILogger logger)
 {
     this.alarmService = alarmService;
     this.ruleService  = ruleService;
     this.log          = logger;
 }
Beispiel #13
0
 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;
 }
Beispiel #17
0
 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'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// ascending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;Created&lt;/strong&gt;
 /// (default).&lt;/p&gt;&lt;p&gt;Note: &lt;strong&gt;orderby&lt;/strong&gt;
 /// and &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually
 /// exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='orderbydesc'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// descending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;Created&lt;/strong&gt;
 /// (default).&lt;/p&gt;&lt;p&gt;Note: &lt;strong&gt;orderby&lt;/strong&gt;
 /// and &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually
 /// exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='unitAccountAccountId'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// Unit.Account.AccountId using the supplied operation and
 /// value.&lt;/p&gt;&lt;p&gt;Valid operations are:
 /// &lt;strong&gt;eq(int)&lt;/strong&gt;&lt;/p&gt;
 /// </param>
 /// <param name='state'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// State using the supplied operation and value.&lt;/p&gt;&lt;p&gt;Valid
 /// operations are:
 /// &lt;strong&gt;eq(alarmstate)&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;state =
 /// ['Unresolved', 'Reject', 'Solved', 'Reset', 'AutoResolved']&lt;/p&gt;
 /// </param>
 /// <param name='top'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Returns the maximum
 /// number of entities. Default and max value is 10000
 /// </param>
 /// <param name='skip'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; 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());
 }
Beispiel #20
0
 /// <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());
 }
Beispiel #21
0
 /// <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());
 }
Beispiel #22
0
 /// <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());
 }
Beispiel #23
0
 /// <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'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// ascending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;Created&lt;/strong&gt;
 /// (default).&lt;/p&gt;&lt;p&gt;Note: &lt;strong&gt;orderby&lt;/strong&gt;
 /// and &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually
 /// exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='orderbydesc'>
 /// &lt;p&gt;&lt;a href='#queryoptions'&gt;Sorts&lt;/a&gt; the result in
 /// descending order by the supplied property.&lt;/p&gt;&lt;p&gt;Valid values
 /// are: &lt;strong&gt;Created&lt;/strong&gt;
 /// (default).&lt;/p&gt;&lt;p&gt;Note: &lt;strong&gt;orderby&lt;/strong&gt;
 /// and &lt;strong&gt;orderbydesc&lt;/strong&gt; are mutually
 /// exclusive.&lt;/p&gt;
 /// </param>
 /// <param name='unitAccountAccountId'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// Unit.Account.AccountId using the supplied operation and
 /// value.&lt;/p&gt;&lt;p&gt;Valid operations are:
 /// &lt;strong&gt;eq(int)&lt;/strong&gt;&lt;/p&gt;
 /// </param>
 /// <param name='created'>
 /// &lt;p&gt;&lt;a href="#queryoptions"&gt;Filters&lt;/a&gt; the result by
 /// Created using the supplied operation and value.&lt;/p&gt;&lt;p&gt;Valid
 /// operations are: &lt;strong&gt;eq(datetime)&lt;/strong&gt;,
 /// &lt;strong&gt;ge(datetime)&lt;/strong&gt;,
 /// &lt;strong&gt;gt(datetime)&lt;/strong&gt;,
 /// &lt;strong&gt;le(datetime)&lt;/strong&gt;,
 /// &lt;strong&gt;lt(datetime)&lt;/strong&gt;&lt;/p&gt;
 /// </param>
 /// <param name='top'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; Returns the maximum
 /// number of entities. Default and max value is 10000
 /// </param>
 /// <param name='skip'>
 /// &lt;a href="#queryoptions"&gt;Query paging&lt;/a&gt; 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);
     }
 }
Beispiel #25
0
 /// <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());
 }
Beispiel #26
0
 /// <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;
 }