/// <summary> /// Initializes a new instance of the <see cref="PartnerOperations" /> class. /// </summary> /// <param name="credentials">Credentials to be used when accessing resources.</param> /// <param name="requestContext">The context used to perform operations.</param> public PartnerOperations(IPartnerCredentials credentials, IRequestContext context) : this() { Credentials = credentials; RequestContext = context; ServiceClient = new PartnerServiceClient(this, PartnerService.Instance.ApiRootUrl); }
public async Task GetCustomersTestAsync() { IPartnerServiceClient partnerService; SeekBasedResourceCollection <Customer> customers; try { using (MockContext context = MockContext.Start(GetType().Name)) { HttpMockServer.Initialize(GetType().Name, "GetCustomersTestAsync", HttpRecorderMode.Playback); partnerService = new PartnerServiceClient( new Uri(PartnerCenterEndpoint), new TestServiceCredentials("STUB_TOKEN"), HttpMockServer.CreateInstance()); customers = await partnerService.Customers.GetAsync().ConfigureAwait(false); Assert.IsNotNull(customers); context.Stop(); } } finally { customers = null; partnerService = null; } }
public static new Partner GetById(int id) { using (PartnerServiceClient client = new PartnerServiceClient()) { return(new Partner(client.GetPartnerById(id))); } }
public Partner() { using (PartnerServiceClient client = new PartnerServiceClient()) { Proxy = client.CreatePartner(); client.Close(); } }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionOperations" /> class. /// </summary> /// <param name="client">Provides the ability to interact with Partner Center.</param> /// <param name="customerId">Identifier for the customer.</param> /// <param name="subscriptionId">Identifier for the subscription.</param> public SubscriptionOperations(PartnerServiceClient client, string customerId, string subscriptionId) { this.client = client; this.customerId = customerId; this.subscriptionId = subscriptionId; subscriptionUtilizationOperations = new Lazy <IUtilizationCollectionOperations>( () => new UtilizationCollectionOperations(client, customerId, subscriptionId)); }
/// <summary> /// Initializes a new instance of the <see cref="PartnerOperations" /> class. /// </summary> /// <param name="credentials">Credentials to be used when accessing resources.</param> /// <param name="requestContext">The context used to perform operations.</param> /// <param name="handlers">List of handlers from top to bottom (outer handler is the first in the list).</param> public PartnerOperations(IPartnerCredentials credentials, IRequestContext requestContext, params DelegatingHandler[] handlers) : this() { Credentials = credentials; RequestContext = requestContext; ServiceClient = new PartnerServiceClient( this, PartnerService.Instance.ApiRootUrl, handlers); }
/// <summary> /// Initializes a new instance of the <see cref="TestBase" /> class. /// </summary> static TestBase() { AuthenticationResult authResult; IPartnerServiceClient client = new PartnerServiceClient(httpClient); authResult = client.RefreshAccessTokenAsync( new Uri(Environment.GetEnvironmentVariable("Authority")), Environment.GetEnvironmentVariable("PartnerCenterEndpoint"), Environment.GetEnvironmentVariable("RefreshToken"), Environment.GetEnvironmentVariable("AppId"), Environment.GetEnvironmentVariable("AppSecret")).GetAwaiter().GetResult(); token = new AuthenticationToken(authResult.AccessToken, authResult.ExpiresOn); }
private static void Main(string[] args) { serviceClient = new PartnerServiceClient(httpClient); RunAsync().ConfigureAwait(false).GetAwaiter().GetResult(); }
/// <summary> /// Performs the execution of the command. /// </summary> protected override void ProcessRecord() { AuthenticationResult authResult; AzureAccount account = new AzureAccount(); #if NETSTANDARD DeviceCodeResult deviceCodeResult; #else AuthorizationResult authorizationResult; #endif IPartnerServiceClient client; PartnerEnvironment environment; Uri authority; string clientId; string resource; if (ParameterSetName.Equals(ServicePrincipalParameterSet, StringComparison.InvariantCultureIgnoreCase)) { account.Properties[AzureAccountPropertyType.ServicePrincipalSecret] = Credential.Password.ConvertToString(); account.Type = AccountType.ServicePrincipal; clientId = string.IsNullOrEmpty(ApplicationId) ? Credential.UserName : ApplicationId; } else { account.Type = AccountType.User; clientId = ApplicationId; } account.Properties[AzureAccountPropertyType.Tenant] = string.IsNullOrEmpty(TenantId) ? AuthenticationConstants.CommonEndpoint : TenantId; environment = PartnerEnvironment.PublicEnvironments[Environment]; client = new PartnerServiceClient(httpClient); authority = new Uri($"{environment.ActiveDirectoryAuthority}{account.Properties[AzureAccountPropertyType.Tenant]}"); resource = string.IsNullOrEmpty(Resource) ? environment.PartnerCenterEndpoint : Resource; if (!string.IsNullOrEmpty(RefreshToken)) { authResult = client.RefreshAccessTokenAsync( authority, resource, RefreshToken, clientId, Credential?.Password.ConvertToString()).GetAwaiter().GetResult(); } else if (account.Type == AccountType.ServicePrincipal && !Consent.ToBool()) { authResult = client.AcquireTokenAsync( authority, resource, clientId, Credential.Password.ConvertToString()).GetAwaiter().GetResult(); } #if NETSTANDARD else { deviceCodeResult = client.AcquireDeviceCodeAsync( authority, resource, clientId, Credential?.Password.ConvertToString()).GetAwaiter().GetResult(); WriteWarning(deviceCodeResult.Message); authResult = client.AcquireTokenByDeviceCodeAsync( authority, deviceCodeResult, Credential?.Password.ConvertToString()).GetAwaiter().GetResult(); }
public OfferOperations(PartnerServiceClient client, string offerId, string country) { this.client = client; this.country = country; this.offerId = offerId; }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionCollectionOperations" /> class. /// </summary> /// <param name="client">Provides the ability to perform HTTP operations.</param> /// <param name="customerId">Identifier for the customer.</param> public SubscriptionCollectionOperations(PartnerServiceClient client, string customerId) { this.client = client; this.customerId = customerId; }
public OfferCollectionOperations(PartnerServiceClient client, string country) { this.client = client; this.country = country; }
public AzureUtilizationCollectionOperations(PartnerServiceClient client, string customerId, string subscriptionId) { this.client = client; this.customerId = customerId; this.subscriptionId = subscriptionId; }
/// <summary> /// Initializes a new instance of the <see cref="CustomerOperations" /> class. /// </summary> /// <param name="client">Provides the ability to perform HTTP operations.</param> /// <param name="customerId">Identifier for the customer.</param> public CustomerOperations(PartnerServiceClient client, string customerId) { this.client = client; this.customerId = customerId; subscriptions = new Lazy <ISubscriptionCollectionOperations>(() => new SubscriptionCollectionOperations(client, customerId)); }
/// <summary> /// Initializes a new instance of the <see cref="CustomerCollectionOperations" /> class. /// </summary> /// <param name="client">Provides the ability to perform HTTP operations.</param> public CustomerCollectionOperations(PartnerServiceClient client) { this.client = client; }
/// <summary> /// Initializes a new instance of the <see cref="AuditRecordCollectionOperations" /> class. /// </summary> /// <param name="client">Provides the ability to perform HTTP operations.</param> public AuditRecordCollectionOperations(PartnerServiceClient client) { this.client = client; }
public OfferCountrySelector(PartnerServiceClient client) { this.client = client; }
public UtilizationCollectionOperations(PartnerServiceClient client, string customerId, string subscriptionId) { azureUtilizationOperations = new Lazy <IAzureUtilizationCollectionOperations>( () => new AzureUtilizationCollectionOperations( client, customerId, subscriptionId)); }