コード例 #1
0
        private void SetUpApi(Config config, statistics.Client.Configuration statsConfig = null, mds.Client.Configuration mdsConfig = null, Configuration deviceConfig = null)
        {
            const string dateFormat = "yyyy-MM-dd'T'HH:mm:ss.fffZ";
            var          auth       = $"{config.AuthorizationPrefix} {config.ApiKey}";

            if (statsConfig == null)
            {
                statsConfig = new statistics.Client.Configuration
                {
                    BasePath       = config.Host,
                    DateTimeFormat = dateFormat,
                    UserAgent      = UserAgent,
                };
                statsConfig.AddApiKey("Authorization", config.ApiKey);
                statsConfig.AddApiKeyPrefix("Authorization", config.AuthorizationPrefix);
                statsConfig.CreateApiClient();
            }

            if (mdsConfig == null)
            {
                mdsConfig = new mds.Client.Configuration
                {
                    BasePath       = config.Host,
                    DateTimeFormat = dateFormat,
                    UserAgent      = UserAgent,
                };
                mdsConfig.AddApiKey("Authorization", config.ApiKey);
                mdsConfig.AddApiKeyPrefix("Authorization", config.AuthorizationPrefix);
                mdsConfig.CreateApiClient();
            }

            if (deviceConfig == null)
            {
                deviceConfig = new device_directory.Client.Configuration
                {
                    BasePath       = config.Host,
                    DateTimeFormat = dateFormat,
                    UserAgent      = UserAgent,
                };
                deviceConfig.AddApiKey("Authorization", config.ApiKey);
                deviceConfig.AddApiKeyPrefix("Authorization", config.AuthorizationPrefix);
                deviceConfig.CreateApiClient();
            }

            DeviceDirectoryApi = new device_directory.Api.DefaultApi(deviceConfig);
            StatisticsApi      = new statistics.Api.StatisticsApi(statsConfig);
            SubscriptionsApi   = new SubscriptionsApi(mdsConfig);
            ResourcesApi       = new ResourcesApi(mdsConfig);
            EndpointsApi       = new EndpointsApi(mdsConfig);
            AccountApi         = new statistics.Api.AccountApi(statsConfig);
            NotificationsApi   = new NotificationsApi(mdsConfig);
            DeviceRequestsApi  = new DeviceRequestsApi(mdsConfig);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectApi" /> class.
        /// </summary>
        /// <param name="config"><see cref="Config" /></param>
        /// <param name="statsConfig">The stats configuration.</param>
        /// <param name="mdsConfig">The MDS configuration.</param>
        /// <param name="deviceConfig">The device configuration.</param>
        internal ConnectApi(Config config, statistics.Client.Configuration statsConfig = null, mds.Client.Configuration mdsConfig = null, device_directory.Client.Configuration deviceConfig = null)
            : base(config)
        {
            forceClear             = config.ForceClear;
            autostartNotifications = config.AutostartNotifications;
            if (autostartNotifications)
            {
                DeliveryMethod = NotificationDeliveryMethod.DeliveryMethod.CLIENT_INITIATED;
            }

            ResourceSubscribtions = new ConcurrentDictionary <string, Resource>();
            SetUpApi(config, statsConfig, mdsConfig, deviceConfig);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceDirectoryApi" /> class.
 /// </summary>
 /// <param name="config">Config.</param>
 /// <param name="deviceConfig">The device configuration.</param>
 /// <example>
 /// This API is intialized with a <see cref="Config" /> object.
 /// <code>
 /// using MbedCloudSDK.Common;
 /// var config = new config(apiKey);
 /// var deviceApi = new DeviceDirectoryApi(config);
 /// </code></example>
 internal DeviceDirectoryApi(Config config, device_directory.Client.Configuration deviceConfig = null)
     : base(config)
 {
     SetUpApi(config, deviceConfig);
 }