• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript WebApi.getBasicHandler函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vso-node-api/WebApi.getBasicHandler函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getBasicHandler函数的具体用法?TypeScript getBasicHandler怎么用?TypeScript getBasicHandler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getBasicHandler函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(username: string, password?: string) {
     if (password !== undefined) {
         // NTLM or Basic
     } else {
         // Personal Access Token
         this._credentialHandler = getBasicHandler("OAuth", username);
     }
 }
开发者ID:Happy-Ferret,项目名称:vsts-vscode,代码行数:8,代码来源:credentialinfo.ts


示例2: constructor

 constructor(username: string, password?: string, domain?: string, workstation?: string) {
     if (username !== undefined && password !== undefined) {
         // NTLM (we don't support Basic auth)
         this._credentialHandler = getNtlmHandler(username, password, domain, workstation);
     } else {
         // Personal Access Token (use username since it is first argument to constructor)
         this._credentialHandler = getBasicHandler(Constants.OAuth, username);
     }
 }
开发者ID:chrisdias,项目名称:vsts-vscode,代码行数:9,代码来源:credentialinfo.ts


示例3: getConnectionData

function getConnectionData(uri: string, username: string, password: string): Q.Promise<locationApi.ConnectionData> {
    const defer = Q.defer<locationApi.ConnectionData>();
    new locationApi.LocationApi(uri, [vstsWebApi.getBasicHandler(username, password)])
        .getConnectionData((err: any, statusCode: number, connectionData: locationApi.ConnectionData) => {
        if (err) {
            err.statusCode = statusCode;
            defer.reject(err);
        }
        else {
            defer.resolve(connectionData);
        }
    });
    return defer.promise;
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:14,代码来源:LocationHelpers.ts


示例4: constructor

 constructor(username: string, password?: string, domain?: string, workstation?: string) {
     if (username !== undefined && password !== undefined) {
         // NTLM (we don't support Basic auth)
         this._username = username;
         this._password = password;
         this._domain = domain;
         this._workstation = workstation;
         this._credentialHandler = getNtlmHandler(this._username, this._password, this._domain, this._workstation);
     } else {
         // Personal Access Token
         this._username = Constants.OAuth;
         this._password = username; //use username since it is first argument to constructor
         this._credentialHandler = getBasicHandler(this._username, this._password);
     }
 }
开发者ID:Microsoft,项目名称:vsts-vscode,代码行数:15,代码来源:extensionrequesthandler.ts


示例5: getBasicHandler

    var promise = new Promise<void>(async (resolve, reject) => {
        var connection = tl.getInput("connection", true);
        var projectId = tl.getInput("project", true);
        var definitionId = tl.getInput("definition", true);
        var buildId = tl.getInput("version", true);
        var itemPattern = tl.getInput("itemPattern", true);
        var downloadPath = tl.getInput("downloadPath", true);

        var endpointUrl = tl.getEndpointUrl(connection, false);
        var username = tl.getEndpointAuthorizationParameter(connection, 'username', true);
        var accessToken = tl.getEndpointAuthorizationParameter(connection, 'apitoken', true)
            || tl.getEndpointAuthorizationParameter(connection, 'password', true);
        var credentialHandler = getBasicHandler(username, accessToken);
        var vssConnection = new WebApi(endpointUrl, credentialHandler);
        var debugMode = tl.getVariable('System.Debug');
        var verbose = debugMode ? debugMode.toLowerCase() != 'false' : false;
        var parallelLimit: number = +tl.getVariable("release.artifact.download.parallellimit");

        var templatePath = path.join(__dirname, 'vsts.handlebars');
        var buildApi = vssConnection.getBuildApi();

        var artifacts = await executeWithRetries("getArtifacts", () => buildApi.getArtifacts(parseInt(buildId), projectId), 3).catch((reason) => {
            reject(reason);
        });

        if (artifacts) {
            var downloadPromises: Array<Promise<any>> = [];
            console.log("Linked artifacts count: " + artifacts.length);
            artifacts.forEach(async function (artifact, index, artifacts) {
                let downloaderOptions = new engine.ArtifactEngineOptions();
                downloaderOptions.itemPattern = itemPattern;
                downloaderOptions.verbose = verbose;

                if (parallelLimit) {
                    downloaderOptions.parallelProcessingLimit = parallelLimit;
                }

                if (artifact.resource.type.toLowerCase() === "container") {
                    let downloader = new engine.ArtifactEngine();
                    var containerParts: string[] = artifact.resource.data.split('/', 3);
                    if (containerParts.length !== 3) {
                        throw new Error(tl.loc("FileContainerInvalidArtifactData"));
                    }

                    var containerId: number = parseInt(containerParts[1]);
                    var containerPath: string = containerParts[2];

                    var itemsUrl = endpointUrl + "/_apis/resources/Containers/" + containerId + "?itemPath=" + encodeURIComponent(containerPath) + "&isShallow=true";
                    itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
                    console.log(tl.loc("DownloadArtifacts", itemsUrl));

                    var variables = {};

                    var handler = username ? new webHandlers.BasicCredentialHandler(username, accessToken) : new webHandlers.PersonalAccessTokenCredentialHandler(accessToken);
                    var webProvider = new providers.WebProvider(itemsUrl, templatePath, variables, handler);
                    var fileSystemProvider = new providers.FilesystemProvider(downloadPath);

                    downloadPromises.push(downloader.processItems(webProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
                        reject(reason);
                    }));
                }
                else if (artifact.resource.type.toLowerCase() === "filepath") {
                    let downloader = new engine.ArtifactEngine();
                    let downloadUrl = artifact.resource.data;
                    let artifactLocation = downloadUrl + '/' + artifact.name;
                    if (!fs.existsSync(artifactLocation)) {
                        console.log(tl.loc("ArtifactNameDirectoryNotFound", artifactLocation, downloadUrl));
                        artifactLocation = downloadUrl;
                    }

                    console.log(tl.loc("DownloadArtifacts", artifactLocation));
                    var fileShareProvider = new providers.FilesystemProvider(artifactLocation);
                    var fileSystemProvider = new providers.FilesystemProvider(downloadPath + '\\' + artifact.name);

                    downloadPromises.push(downloader.processItems(fileShareProvider, fileSystemProvider, downloaderOptions).catch((reason) => {
                        reject(reason);
                    }));
                }
                else {
                    console.log(tl.loc('UnsupportedArtifactType', artifact.resource.type));
                }
            });

            Promise.all(downloadPromises).then(() => {
                console.log(tl.loc('ArtifactsSuccessfullyDownloaded', downloadPath));
                resolve();
            }).catch((error) => {
                reject(error);
            });
        }
    });
开发者ID:Microsoft,项目名称:vsts-rm-extensions,代码行数:91,代码来源:download.ts


示例6: run

async function run() {
    try {
        tl.debug("Starting Coverage Gate task");

        var tpcUri = tl.getVariable("System.TeamFoundationCollectionUri");
        var teamProject = tl.getVariable("System.TeamProject");
        var buildId = parseInt(tl.getVariable("Build.BuildId"));
        var minDelta = parseInt(tl.getInput("minDelta", true));
        var operator = tl.getInput("operator", true);
        var username = tl.getInput("username", false);
        var password = tl.getInput("password", false);
        tl.debug(`minDelta: ${minDelta}`);
        tl.debug(`operator: ${operator}`);
        tl.debug(`username: ${username}`);

        // handle creds
        var credOk = true;
        var credHandler: vstsInterfaces.IRequestHandler;
        var accessToken = tl.getVariable("System.AccessToken");
        if (!accessToken || accessToken.length === 0) {
            if (username && username.length > 0) {
                tl.debug("Detected username: creating basic cred handler");
                credHandler = webApi.getBasicHandler(username, password);
            } else {
                tl.setResult(tl.TaskResult.Failed, "Could not find token for autheniticating. Please enable OAuth token in Build/Release Options or supply username/password.");
                credOk = false;
            }
        } else {
            tl.debug("Detected token: creating bearer cred handler");
            credHandler = webApi.getBearerHandler(accessToken);
        }

        if (credOk) {
            var vsts = new webApi.WebApi(tpcUri, credHandler);

            // get previous successful builds
            tl.debug("Connecting to test API");
            var testApi = vsts.getTestApi();

            tl.debug("Getting coverage data");
            // 1 = modules, 2 = function, 4 = block
            var covData = await testApi.getCodeCoverageSummary(teamProject, buildId);

            tl.debug("Analyzing coverage data");
            if (covData) {
                var data = covData.coverageData[0];
                var trends = data.coverageStats.filter(c => c.isDeltaAvailable)
                    .map(u => {
                        return {
                            Label: u.label,
                            Delta: u.delta
                        };
                    });
                if (trends.length === 0){
                    tl.setResult(tl.TaskResult.Failed, `There are no coverage deltas. Make sure you have at least 2 builds.`);
                }
                var fail = trends.some(t => operator === 'lt' ? t.Delta < minDelta : t.Delta <= minDelta);
                if (fail) {
                    tl.setResult(tl.TaskResult.Failed, `Coverage delta is below the threshold of ${minDelta}`);
                }
            } else {
                tl.setResult(tl.TaskResult.Failed, "No coverage data for build. Cannot determine trend.");
            }
            tl.setResult(tl.TaskResult.Succeeded, `Code coverage delta is above the threshold of ${minDelta}`);
        }
    } catch (err) {
        tl.debug("Caught an error - logging");
        let msg = err;
        if (err.message) {
            msg = err.message;
        }
        tl.setResult(tl.TaskResult.Failed, msg);
    }
    tl.debug("Leaving Coverage Gate task");
}
开发者ID:xiangyan99,项目名称:cols-agent-tasks,代码行数:75,代码来源:coverageGate.ts


示例7: getRawGalleryAPI

export function getRawGalleryAPI(pat: string): IGalleryApi {
	const authHandler = getBasicHandler('oauth', pat);
	const vsoapi = new WebApi('oauth', authHandler);
	return vsoapi.getGalleryApi('https://marketplace.visualstudio.com');
}
开发者ID:fjsnogueira,项目名称:vscode-vsce,代码行数:5,代码来源:util.ts



注:本文中的vso-node-api/WebApi.getBasicHandler函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript WebApi.getBearerHandler函数代码示例发布时间:2022-05-25
下一篇:
TypeScript HttpClient.HttpCallbackClient类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap