Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabricksClient"/> class.
 /// </summary>
 /// <param name="clusterApi">The cluster API implementation.</param>
 /// <param name="jobsApi">The jobs API implementation.</param>
 /// <param name="dbfsApi">The dbfs API implementation.</param>
 /// <param name="secretsApi">The secrets API implementation.</param>
 /// <param name="groupsApi">The groups API implementation.</param>
 /// <param name="librariesApi">The libraries API implementation.</param>
 /// <param name="tokenApi">The token API implementation.</param>
 /// <param name="workspaceApi">The workspace API implementation.</param>
 ///
 private DatabricksClient(IClustersApi clusterApi, IJobsApi jobsApi, IDbfsApi dbfsApi, ISecretsApi secretsApi,
                          IGroupsApi groupsApi, ILibrariesApi librariesApi, ITokenApi tokenApi, IWorkspaceApi workspaceApi)
 {
     this.Clusters  = clusterApi;
     this.Jobs      = jobsApi;
     this.Dbfs      = dbfsApi;
     this.Secrets   = secretsApi;
     this.Groups    = groupsApi;
     this.Libraries = librariesApi;
     this.Token     = tokenApi;
     this.Workspace = workspaceApi;
 }
        /// <summary>
        /// 获取Access Token
        /// </summary>
        /// <returns></returns>
        public virtual async Task <string> GetAccessTokenAsync()
        {
            WxPublicAccountOption options = weChatFuncs?.GetWeChatOptions();
            string token = weChatFuncs?.GetAccessTokenByAppId(options?.AppId);

            if (string.IsNullOrEmpty(token))
            {
                ITokenApi      tokenApi = serviceProvider.GetService <ITokenApi>();
                TokenApiResult result   = await tokenApi.GetAsync(options.AppId, options.AppSecret);

                weChatFuncs?.CacheAccessToken(options.AppId, result.AccessToken);
                return(result.AccessToken);
            }
            return(token);
        }
Beispiel #3
0
 /// <summary>
 /// Create client object with mock implementation. This is for unit testing purpose.
 /// </summary>
 public static DatabricksClient CreateClient(IClustersApi clusterApi, IJobsApi jobsApi, IDbfsApi dbfsApi,
                                             ISecretsApi secretsApi, IGroupsApi groupsApi, ILibrariesApi librariesApi, ITokenApi tokenApi,
                                             IWorkspaceApi workspaceApi, IInstancePoolApi instancePoolApi)
 {
     return(new DatabricksClient(clusterApi, jobsApi, dbfsApi, secretsApi, groupsApi, librariesApi, tokenApi,
                                 workspaceApi, instancePoolApi));
 }
 public TokenApiTest(TestWebApplicationFactory webApplicationFactory, ITestOutputHelper output) : base(webApplicationFactory, output)
 {
     tokenApi    = GetRequiredService <ITokenApi>();
     weChatFuncs = GetRequiredService <WxFuncs>();
 }
 /// <summary>
 /// Creates an instance of the LoanPayClient using custom api implementations
 /// </summary>
 /// <param name="identityApi">IdentityApi to be used by the LoanPayClient</param>
 /// <param name="loanPayApi">LoanPayApi to be used by the LoanPayClient</param>
 /// <param name="tokenApi">TokenApi to be used by the LoanPayClient</param>
 public Client(IIdentityApi identityApi, ILoanPayApi loanPayApi, ITokenApi tokenApi)
 {
     IdentityApi = identityApi;
     LoanPayApi  = loanPayApi;
     TokenApi    = tokenApi;
 }
 /// <summary>
 /// Creates an instance of the LoanPayClient
 /// </summary>
 /// <param name="httpClient">Sets the HttpClient to be used by the LoanPayClient</param>
 /// <param name="environmentManager">Sets the environment to be used by the LoanPayClient</param>
 /// <param name="identityClientId">Sets the Identity Client Id to be used by the LoanPayClient</param>
 /// <param name="identityClientSecret">Sets the Identity Client Secret to be used by the LoanPayClient</param>
 public Client(HttpClient httpClient, IEnvironmentManager environmentManager, string identityClientId, string identityClientSecret)
 {
     IdentityApi = new IdentityApi(httpClient, environmentManager, identityClientId, identityClientSecret);
     LoanPayApi  = new LoanPayApi(httpClient, environmentManager);
     TokenApi    = new TokenApi(httpClient, environmentManager);
 }