當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript WebApi.getBasicHandler函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。