public void Register( EventNotificationConfig config ) {
            string path = template.UrlFor(UrlTemplate.CALLBACK_PATH).Build();
            Callback callback = config.ToAPICallback();
            string json = JsonConvert.SerializeObject(callback, settings);

            restClient.Post(path, json);
        }
        override public void Execute()
        {
            // Register for event notification
            eslClient.EventNotificationService.Register(EventNotificationConfigBuilder.NewEventNotificationConfig(URL)
                                                        .ForEvent(EVENT1)
                                                        .ForEvent(EVENT2)
                                                        .ForEvent(EVENT3)
                                                        .ForEvent(EVENT4)
                                                        .ForEvent(EVENT5)
                                                        .ForEvent(EVENT6)
                                                        .ForEvent(EVENT7)
                                                        .ForEvent(EVENT8)
                                                        .ForEvent(EVENT9)
                                                        .ForEvent(EVENT10)
                                                        .ForEvent(EVENT11)
                                                        .ForEvent(EVENT12)
                                                        .ForEvent(EVENT13)
                                                        .ForEvent(EVENT14)
                                                        .ForEvent(EVENT15)
                                                        .ForEvent(EVENT16)
                                                        .ForEvent(EVENT17)
                                                        .ForEvent(EVENT18));

            // Get the registered event notifications
            eventNotificationConfig = eslClient.EventNotificationService.GetEventNotificationConfig();
        }
Ejemplo n.º 3
0
        public void Register(EventNotificationConfig config)
        {
            string   path     = template.UrlFor(UrlTemplate.CALLBACK_PATH).Build();
            Callback callback = config.ToAPICallback();
            string   json     = JsonConvert.SerializeObject(callback, settings);

            restClient.Post(path, json);
        }
Ejemplo n.º 4
0
        private Silanis.ESL.SDK.EventNotificationConfig CreateTypicalSDKEventNotificationConfig()
        {
            EventNotificationConfig eventNotificationConfig = EventNotificationConfigBuilder.NewEventNotificationConfig("callback url")
                                                              .ForEvent(NotificationEvent.PACKAGE_DECLINE)
                                                              .ForEvent(NotificationEvent.PACKAGE_RESTORE)
                                                              .ForEvent(NotificationEvent.SIGNER_COMPLETE)
                                                              .build();

            return(eventNotificationConfig);
        }
Ejemplo n.º 5
0
        override public void Execute()
        {
            // Register for event notification
            eslClient.EventNotificationService.Register(EventNotificationConfigBuilder.NewEventNotificationConfig(URL)
                                                        .ForEvent(EVENT1)
                                                        .ForEvent(EVENT2)
                                                        .ForEvent(EVENT3));

            // Get the registered event notifications
            eventNotificationConfig = eslClient.EventNotificationService.GetEventNotificationConfig();
        }
Ejemplo n.º 6
0
        // [END iot_send_command]

        // [START iot_create_registry]
        public static object CreateRegistry(string projectId, string cloudRegion,
                                            string registryId, string pubsubTopic)
        {
            var cloudIot = CreateAuthorizedClient();
            // The resource name of the location associated with the key rings.
            var parent = $"projects/{projectId}/locations/{cloudRegion}";

            Console.WriteLine(parent);

            try
            {
                Console.WriteLine($"Creating {registryId}");
                DeviceRegistry body = new DeviceRegistry()
                {
                    Id = registryId,
                };
                body.EventNotificationConfigs =
                    new List <EventNotificationConfig>();
                var toAdd = new EventNotificationConfig()
                {
                    PubsubTopicName = pubsubTopic.StartsWith("projects/") ?
                                      pubsubTopic : $"projects/{projectId}" +
                                      $"/topics/{pubsubTopic}",
                };
                body.EventNotificationConfigs.Add(toAdd);
                var registry = cloudIot
                               .Projects
                               .Locations
                               .Registries
                               .Create(body, parent)
                               .Execute();
                Console.WriteLine("Registry: ");
                Console.WriteLine($"{registry.Id}");
                Console.WriteLine($"\tName: {registry.Name}");
                Console.WriteLine($"\tHTTP Enabled: " +
                                  $"{registry.HttpConfig.HttpEnabledState}");
                Console.WriteLine($"\tMQTT Enabled: " +
                                  $"{registry.MqttConfig.MqttEnabledState}");
            }
            catch (Google.GoogleApiException e)
            {
                Console.WriteLine(e.Message);
                if (e.Error != null)
                {
                    return(e.Error.Code);
                }
                return(-1);
            }
            return(0);
        }
Ejemplo n.º 7
0
        public void VerifyResult()
        {
            EventNotificationRegistrationExample example = new EventNotificationRegistrationExample(Props.GetInstance());

            example.Run();

            EventNotificationConfig eventNotificationConfig = example.EventNotificationConfig;

            Assert.IsNotNull(eventNotificationConfig);
            Assert.AreEqual(eventNotificationConfig.Url, EventNotificationRegistrationExample.URL);
            Assert.AreEqual(eventNotificationConfig.NotificationEvents.Count, 3);
            Assert.AreEqual(eventNotificationConfig.NotificationEvents[0].ToString(), EventNotificationRegistrationExample.EVENT1.ToString());
            Assert.AreEqual(eventNotificationConfig.NotificationEvents[1].ToString(), EventNotificationRegistrationExample.EVENT2.ToString());
            Assert.AreEqual(eventNotificationConfig.NotificationEvents[2].ToString(), EventNotificationRegistrationExample.EVENT3.ToString());
        }
 private void AssertEvents(EventNotificationConfig config, IList <NotificationEvent> events)
 {
     foreach (NotificationEvent notificationEvent in events)
     {
         bool found = false;
         foreach (NotificationEvent receivedEvent in config.NotificationEvents)
         {
             if (receivedEvent.ToString().Equals(notificationEvent.ToString()))
             {
                 found = true;
                 break;
             }
         }
         Assert.IsTrue(found, "Callback has wrong event for EVENT" + (events.IndexOf(notificationEvent) + 1));
     }
 }
Ejemplo n.º 9
0
        override public void Execute()
        {
            // Register for event notification
            events.Add(EVENT1);
            events.Add(EVENT2);
            events.Add(EVENT3);
            events.Add(EVENT4);
            events.Add(EVENT5);
            events.Add(EVENT6);
            events.Add(EVENT7);
            events.Add(EVENT8);
            events.Add(EVENT9);
            events.Add(EVENT10);
            events.Add(EVENT11);
            events.Add(EVENT12);
            events.Add(EVENT13);
            events.Add(EVENT14);
            events.Add(EVENT15);
            events.Add(EVENT16);
            events.Add(EVENT17);
            events.Add(EVENT18);
            events.Add(EVENT19);
            events.Add(EVENT20);

            eslClient.EventNotificationService.Register(EventNotificationConfigBuilder.NewEventNotificationConfig(URL)
                                                        .WithKey(KEY).SetEvents(events));

            // Get the registered event notifications
            config = eslClient.EventNotificationService.GetEventNotificationConfig();

            // Register event notifications for dynamics2013 connector
            connectorsEvents.Add(EVENT1);
            connectorsEvents.Add(EVENT3);
            connectorsEvents.Add(EVENT6);
            connectorsEvents.Add(EVENT9);
            connectorsEvents.Add(EVENT11);
            connectorsEvents.Add(EVENT12);
            connectorsEvents.Add(EVENT14);
            connectorsEvents.Add(EVENT17);
            connectorsEvents.Add(EVENT18);

            eslClient.EventNotificationService.Register(ORIGIN, EventNotificationConfigBuilder.NewEventNotificationConfig(CONNECTORS_URL)
                                                        .WithKey(CONNECTORS_KEY).SetEvents(connectorsEvents));

            // Get the registered event notifications for dynamics2013 connector
            connectorsConfig = eslClient.EventNotificationService.GetEventNotificationConfig(ORIGIN);
        }
        public void VerifyResult()
        {
            EventNotificationRegistrationExample example = new EventNotificationRegistrationExample(Props.GetInstance());

            example.Run();

            EventNotificationConfig eventNotificationConfig = example.EventNotificationConfig;

            Assert.IsNotNull(eventNotificationConfig);
            Assert.AreEqual(eventNotificationConfig.Url, example.URL);
            Assert.AreEqual(eventNotificationConfig.NotificationEvents.Count, 18);

            List <NotificationEvent> eventList = new List <NotificationEvent>();

            eventList.Add(example.EVENT1);
            eventList.Add(example.EVENT2);
            eventList.Add(example.EVENT3);
            eventList.Add(example.EVENT4);
            eventList.Add(example.EVENT5);
            eventList.Add(example.EVENT6);
            eventList.Add(example.EVENT7);
            eventList.Add(example.EVENT8);
            eventList.Add(example.EVENT9);
            eventList.Add(example.EVENT10);
            eventList.Add(example.EVENT11);
            eventList.Add(example.EVENT12);
            eventList.Add(example.EVENT13);
            eventList.Add(example.EVENT14);
            eventList.Add(example.EVENT15);
            eventList.Add(example.EVENT16);
            eventList.Add(example.EVENT17);
            eventList.Add(example.EVENT18);

            foreach (NotificationEvent notificationEvent in eventList)
            {
                bool found = false;
                foreach (NotificationEvent receivedEvent in eventNotificationConfig.NotificationEvents)
                {
                    if (receivedEvent.ToString().Equals(notificationEvent.ToString()))
                    {
                        found = true;
                        break;
                    }
                }
                Assert.IsTrue(found, "Callback has wrong event for EVENT" + (eventList.IndexOf(notificationEvent) + 1));
            }
        }
        public void VerifyResult()
        {
            EventNotificationRegistrationExample example = new EventNotificationRegistrationExample();

            example.Run();

            EventNotificationConfig config = example.config;

            Assert.IsNotNull(config);
            Assert.AreEqual(config.Url, example.URL);
            Assert.AreEqual(config.Key, example.KEY);
            Assert.AreEqual(config.NotificationEvents.Count, 18);

            AssertEvents(config, example.events);

            EventNotificationConfig connectorsConfig = example.connectorsConfig;

            Assert.IsNotNull(connectorsConfig);
            Assert.AreEqual(connectorsConfig.Url, example.CONNECTORS_URL);
            Assert.AreEqual(connectorsConfig.Key, example.CONNECTORS_KEY);
            Assert.AreEqual(connectorsConfig.NotificationEvents.Count, 9);

            AssertEvents(connectorsConfig, example.connectorsEvents);
        }
 /// <summary>
 /// Registers to receive notifications sent by e-SL that are described by the config parameter passed to this method.
 /// </summary>
 /// <param name="origin">The origin of the package.</param>
 /// <param name="config">Describes the event notification of interest.</param>
 public void Register(string origin, EventNotificationConfig config)
 {
     apiClient.Register(origin, new EventNotificationConfigConverter(config).ToAPICallback());
 }
 /// <summary>
 /// Registers to receive notifications sent by e-SL that are described by the config parameter passed to this method.
 /// </summary>
 /// <param name="config">Describes the event notification of interest.</param>
 public void Register(EventNotificationConfig config)
 {
     apiClient.Register(new EventNotificationConfigConverter(config).ToAPICallback());
 }
		/// <summary>
		/// Registers to receive notifications sent by e-SL that are described by the config parameter passed to this method.
		/// </summary>
		/// <param name="config">Describes the event notification of interest.</param>
		public void Register(EventNotificationConfig config)
		{
            apiClient.Register( new EventNotificationConfigConverter(config).ToAPICallback() );
		}