/// <summary> /// Creates a client of the requested type that supports the given credential and version. /// </summary> /// <typeparam name="T">The type of client to create.</typeparam> /// <param name="credential">A credential to be used by the client.</param> /// <param name="version">A version that the client must support.</param> /// <param name="token">A cancellation token to be used to cancel operations.</param> /// <returns>An OpenStack client.</returns> public static IOpenStackClient CreateClient <T>(IOpenStackCredential credential, CancellationToken token, string version) where T : IOpenStackClient { credential.AssertIsNotNull("credential", "Cannot create a client with a null credential."); var locator = new ServiceLocator(); var clientManager = locator.Locate <IOpenStackClientManager>(); return(clientManager.CreateClient <T>(credential, token, version)); }
/// <summary> /// Creates a new instance of the IdentityServiceRestClient class. /// </summary> /// <param name="credential">The credential to be used by this client.</param> /// <param name="cancellationToken">The cancellation token to be used by this client.</param> /// <param name="serviceLocator">A service locator to be used to locate/inject dependent services.</param> public IdentityServiceRestClient(IOpenStackCredential credential, CancellationToken cancellationToken, IServiceLocator serviceLocator) { credential.AssertIsNotNull("credential"); cancellationToken.AssertIsNotNull("cancellationToken"); serviceLocator.AssertIsNotNull("serviceLocator", "Cannot create an identity service rest client with a null service locator."); this.Credential = credential; this.CancellationToken = cancellationToken; this.ServiceLocator = serviceLocator; }
/// <summary> /// Creates a new instance of the IdentityServicePocoClient class. /// </summary> /// <param name="credential">The credential to be used when interacting with OpenStack.</param> /// <param name="cancellationToken">The cancellation token to be used when interacting with OpenStack.</param> /// <param name="serviceLocator">A service locator to be used to locate/inject dependent services.</param> public IdentityServicePocoClient(IOpenStackCredential credential, string serviceName, CancellationToken cancellationToken, IServiceLocator serviceLocator) { credential.AssertIsNotNull("credential"); cancellationToken.AssertIsNotNull("cancellationToken"); serviceLocator.AssertIsNotNull("serviceLocator", "Cannot create an identity service poco client with a null service locator."); serviceName.AssertIsNotNullOrEmpty("serviceName", "Cannot create an identity service poco client with a null or empty service name."); this.credential = credential; this.cancellationToken = cancellationToken; this.ServiceLocator = serviceLocator; this.ServiceName = serviceName; }