Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the Sample class.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        /// <param name="tenantId">Identifier for the tenant.</param>
        /// <param name="clientId">Identifier for the client.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="accountEndpoint">The account endpoint.</param>
        /// <param name="instance">The instance.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="deviceId">Identifier for the device.</param>
        /// <param name="deviceTag">Device tag.</param>
        /// <param name="delete">Boolean flag to indicate whether the update should be deleted when finished.</param>
        public Sample(string tenantId, string clientId, string clientSecret, string accountEndpoint, string instance, string connectionString, string deviceId, string deviceTag, bool delete)
        {
            if (tenantId == null)
            {
                throw new ArgumentNullException(nameof(tenantId));
            }
            if (clientId == null)
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (clientSecret == null)
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }

            _accountEndpoint  = accountEndpoint ?? throw new ArgumentNullException(nameof(accountEndpoint));
            _instanceId       = instance ?? throw new ArgumentNullException(nameof(instance));
            _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
            _deviceId         = deviceId ?? throw new ArgumentNullException(nameof(deviceId));
            _deviceTag        = deviceTag ?? throw new ArgumentNullException(nameof(deviceTag));
            _delete           = delete;

            var credentials = new ClientSecretCredential(tenantId, clientId, clientSecret);

            _updatesClient     = new UpdatesClient(accountEndpoint, instance, credentials);
            _devicesClient     = new DevicesClient(accountEndpoint, instance, credentials);
            _deploymentsClient = new DeploymentsClient(accountEndpoint, instance, credentials);
        }
Esempio n. 2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();
            ExecuteClientAction(() =>
            {
                string resourceGroupName  = this.ResourceGroupName;
                string providerName       = this.ProviderName;
                string resourceParentType = this.ResourceParentType;
                string resourceParentName = this.ResourceParentName;
                string resourceType       = this.ResourceType;
                string resourceName       = this.ResourceName;

                var result = (!string.IsNullOrEmpty(resourceParentType) && !string.IsNullOrEmpty(resourceParentName)) ?
                             UpdatesClient.ListParent(resourceGroupName, providerName, resourceParentType, resourceParentName, resourceType, resourceName) :
                             UpdatesClient.List(resourceGroupName, providerName, resourceType, resourceName);

                var psObject = new List <PSUpdate>();

                foreach (var update in result)
                {
                    PSUpdate psUpdate = new PSUpdate();
                    MaintenanceAutomationAutoMapperProfile.Mapper.Map <Update, PSUpdate>(update, psUpdate);
                    psObject.Add(psUpdate);
                }

                WriteObject(psObject);
            });
        }
Esempio n. 3
0
 public TvDbClient(HttpClient client, TvDBTokenAccessor tokenAccessor, IOptions <TvdbClientOptions> options)
 {
     Series         = new SeriesClient(client);
     Search         = new SearchClient(client);
     Episodes       = new EpisodesClient(client);
     Updates        = new UpdatesClient(client);
     Languages      = new LanguagesClient(client);
     Users          = new UsersClient(client);
     Authentication = new AuthenticationClient(client, tokenAccessor, options);
 }
Esempio n. 4
0
        public TVDBClient(
            HttpClient client, IOptions <TVDBClientOptions> options, TVDBContext context)
        {
            if (!options.Value.ShareContextBetweenClients)
            {
                // If we don't want to share the context, we are creating one just for this client
                context = new TVDBContext();
            }

            Series         = new SeriesClient(client, options, context);
            Search         = new SearchClient(client, options, context);
            Episodes       = new EpisodesClient(client, options, context);
            Updates        = new UpdatesClient(client, options, context);
            Languages      = new LanguagesClient(client, options, context);
            Users          = new UsersClient(client, options, context);
            Authentication = new AuthenticationClient(client, options, context);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GoodreadsClient"/> class.
        /// Use this constructor if you already have OAuth permissions for the user.
        /// </summary>
        /// <param name="apiKey">Your Goodreads API key.</param>
        /// <param name="apiSecret">Your Goodreads API secret.</param>
        /// <param name="accessToken">The user's OAuth access token.</param>
        /// <param name="accessSecret">The user's OAuth access secret.</param>
        public GoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret)
        {
            var client = new RestClient(new Uri(GoodreadsUrl))
            {
                UserAgent = "goodreads-dotnet"
            };

            client.AddDefaultParameter("key", apiKey, ParameterType.QueryString);
            client.AddDefaultParameter("format", "xml", ParameterType.QueryString);

            var apiCredentials = new ApiCredentials(client, apiKey, apiSecret, accessToken, accessSecret);

            // Setup the OAuth authenticator if they have passed on the appropriate tokens
            if (!string.IsNullOrWhiteSpace(accessToken) &&
                !string.IsNullOrWhiteSpace(accessSecret))
            {
                client.Authenticator = OAuth1Authenticator.ForProtectedResource(
                    apiKey, apiSecret, accessToken, accessSecret);
            }

            Connection       = new Connection(client, apiCredentials);
            Authors          = new AuthorsClient(Connection);
            Books            = new BooksClient(Connection);
            Shelves          = new ShelvesClient(Connection);
            Users            = new UsersClient(Connection);
            Reviews          = new ReviewsClient(Connection);
            Series           = new SeriesClient(Connection);
            AuthorsFollowing = new AuthorsFollowingClient(Connection);
            Events           = new EventsClient(Connection);
            Followers        = new FollowersClient(Connection);
            Friends          = new FriendsClient(Connection);
            Notifications    = new NotificationsClient(Connection);
            Groups           = new GroupClient(Connection);
            Quotes           = new QuotesClient(Connection);
            UserStatuses     = new UserStatusesClient(Connection);
            Updates          = new UpdatesClient(Connection);
            Recommendations  = new RecommendationsClient(Connection);
            ReadStatuses     = new ReadStatusesClient(Connection);
        }
            public async Task GetFriendsUpdates()
            {
                var updates = await UpdatesClient.GetFriendsUpdates(UpdateType.Reviews);

                Assert.NotNull(updates);
            }