2015-07-24 00:18:52 +03:00
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces');
|
|
|
|
import basem = require('./ClientApiBases');
|
|
|
|
import buildm = require('./BuildApi');
|
|
|
|
import corem = require('./CoreApi');
|
|
|
|
import filecontainerm = require('./FileContainerApi');
|
2015-08-11 22:27:06 +03:00
|
|
|
import gallerym = require('./GalleryApi');
|
2015-07-24 00:18:52 +03:00
|
|
|
import gitm = require('./GitApi');
|
|
|
|
import taskagentm = require('./TaskAgentApi');
|
|
|
|
import taskm = require('./TaskApi');
|
|
|
|
import testm = require('./TestApi');
|
|
|
|
import tfvcm = require('./TfvcApi');
|
|
|
|
import workitemtrackingm = require('./WorkItemTrackingApi');
|
2016-02-09 17:59:39 +03:00
|
|
|
import releasem = require('./ReleaseApi');
|
2015-07-24 00:18:52 +03:00
|
|
|
|
|
|
|
import apivm = require('./handlers/apiversion');
|
|
|
|
import basicm = require('./handlers/basiccreds');
|
|
|
|
import bearm = require('./handlers/bearertoken');
|
2016-07-06 16:54:51 +03:00
|
|
|
import ntlmm = require('./handlers/ntlm');
|
2016-07-28 05:16:44 +03:00
|
|
|
import patm = require('./handlers/personalaccesstoken');
|
2015-07-24 00:18:52 +03:00
|
|
|
|
2015-08-04 18:54:10 +03:00
|
|
|
/**
|
|
|
|
* Methods to return handler objects (see handlers folder)
|
|
|
|
*/
|
|
|
|
export function getVersionHandler(apiVersion: string) {
|
|
|
|
return new apivm.ApiVersionHandler(apiVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getBasicHandler(username: string, password: string) {
|
|
|
|
return new basicm.BasicCredentialHandler(username, password);
|
|
|
|
}
|
|
|
|
|
2016-07-06 16:54:51 +03:00
|
|
|
export function getNtlmHandler(username: string, password: string, workstation?: string, domain?: string) {
|
|
|
|
return new ntlmm.NtlmCredentialHandler(username, password, workstation, domain);
|
|
|
|
}
|
|
|
|
|
2015-08-04 18:54:10 +03:00
|
|
|
export function getBearerHandler(token) {
|
|
|
|
return new bearm.BearerCredentialHandler(token);
|
|
|
|
}
|
|
|
|
|
2016-07-28 05:16:44 +03:00
|
|
|
export function getPersonalAccessTokenHandler(token) {
|
|
|
|
return new patm.PersonalAccessTokenCredentialHandler(token);
|
|
|
|
}
|
|
|
|
|
2015-07-24 00:18:52 +03:00
|
|
|
// ---------------------------------------------------------------------------
|
2015-07-24 00:34:31 +03:00
|
|
|
// Factory to return client apis
|
|
|
|
// When new APIs are added, two methods must be added here to instantiate the
|
|
|
|
// API and its corresponding Q Promise-wrapped API
|
2015-07-24 00:18:52 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
export class WebApi {
|
|
|
|
|
|
|
|
serverUrl: string;
|
|
|
|
authHandler: VsoBaseInterfaces.IRequestHandler;
|
|
|
|
|
|
|
|
/*
|
2015-07-24 00:34:31 +03:00
|
|
|
* Factory to return client apis and handlers
|
2015-07-24 00:18:52 +03:00
|
|
|
* @param defaultServerUrl default server url to use when creating new apis from factory methods
|
|
|
|
* @param defaultAuthHandler default authentication credentials to use when creating new apis from factory methods
|
|
|
|
*/
|
|
|
|
constructor(serverUrl: string, authHandler: VsoBaseInterfaces.IRequestHandler) {
|
|
|
|
this.serverUrl = serverUrl;
|
|
|
|
this.authHandler = authHandler;
|
|
|
|
}
|
|
|
|
|
2015-07-24 00:34:31 +03:00
|
|
|
/**
|
|
|
|
* Each factory method can take a serverUrl and a list of handlers
|
|
|
|
* if these aren't provided, the default url and auth handler given to the constructor for this class will be used
|
|
|
|
*/
|
2015-07-24 00:18:52 +03:00
|
|
|
public getBuildApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): buildm.IBuildApi {
|
|
|
|
return new buildm.BuildApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
2015-07-24 00:34:31 +03:00
|
|
|
/**
|
2016-07-28 04:27:13 +03:00
|
|
|
* Each API has a method here to create the client.
|
2015-07-24 00:34:31 +03:00
|
|
|
*/
|
2015-07-24 00:18:52 +03:00
|
|
|
public getCoreApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): corem.ICoreApi {
|
|
|
|
return new corem.CoreApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getFileContainerApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): filecontainerm.IFileContainerApi {
|
|
|
|
return new filecontainerm.FileContainerApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
2015-08-11 22:27:06 +03:00
|
|
|
public getGalleryApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): gallerym.IGalleryApi {
|
|
|
|
return new gallerym.GalleryApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
2015-07-24 00:18:52 +03:00
|
|
|
public getGitApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): gitm.IGitApi {
|
|
|
|
return new gitm.GitApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getTaskApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskm.ITaskApi {
|
|
|
|
return new taskm.TaskApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getTaskAgentApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): taskagentm.ITaskAgentApi {
|
|
|
|
return new taskagentm.TaskAgentApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getTestApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): testm.ITestApi {
|
|
|
|
return new testm.TestApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getTfvcApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): tfvcm.ITfvcApi {
|
|
|
|
return new tfvcm.TfvcApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getWorkItemTrackingApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): workitemtrackingm.IWorkItemTrackingApi {
|
|
|
|
return new workitemtrackingm.WorkItemTrackingApi(serverUrl, handlers);
|
|
|
|
}
|
|
|
|
|
2016-02-09 17:59:39 +03:00
|
|
|
public getReleaseApi(serverUrl: string = this.serverUrl, handlers: VsoBaseInterfaces.IRequestHandler[] = [this.authHandler]): releasem.IReleaseApi {
|
|
|
|
return new releasem.ReleaseApi(serverUrl, handlers);
|
2015-08-20 18:55:10 +03:00
|
|
|
}
|
2015-07-24 00:18:52 +03:00
|
|
|
}
|