How to use the typed-rest-client/RestClient.RestClient function in typed-rest-client

To help you get started, we’ve selected a few typed-rest-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / azure-pipelines-tool-lib / sample.ts View on Github external
async function queryLatestMatch(versionSpec: string): Promise {
    //
    // Hopefully your tool supports an easy way to get a version list.
    // Node offers a json list of versions.
    //
    let dataFileName: string;
    switch (osPlat) {
        case "linux": dataFileName = "linux-" + osArch; break;
        case "darwin": dataFileName = "osx-" + osArch + '-tar'; break;
        case "win32": dataFileName = "win-" + osArch + '-exe'; break;
        default: throw new Error(`Unexpected OS '${osPlat}'`);
    }

    let versions: string[] = [];
    let dataUrl = "https://nodejs.org/dist/index.json";
    let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
    let nodeVersions: INodeVersion[] = (await rest.get(dataUrl)).result;
    nodeVersions.forEach((nodeVersion:INodeVersion) => {
        //
        // Ensure this version supports your os and platform.
        //
        if (nodeVersion.files.indexOf(dataFileName) >= 0) {
            versions.push(nodeVersion.version);
        }
    });

    //
    // If there is no data driven way to get versions supported,
    // a last option is to tool.scrape() with a regex.
    //
    // For example:
    //      let scrapeUrl = 'https://nodejs.org/dist/';
github microsoft / azure-pipelines-tasks / Tasks / UseNodeV1 / installer.ts View on Github external
async function queryLatestMatch(versionSpec: string): Promise {
    // node offers a json list of versions
    let dataFileName: string;
    switch (osPlat) {
        case "linux": dataFileName = "linux-" + osArch; break;
        case "darwin": dataFileName = "osx-" + osArch + '-tar'; break;
        case "win32": dataFileName = "win-" + osArch + '-exe'; break;
        default: throw new Error(`Unexpected OS '${osPlat}'`);
    }

    let versions: string[] = [];
    let dataUrl = "https://nodejs.org/dist/index.json";
    let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
    let nodeVersions: INodeVersion[] = (await rest.get(dataUrl)).result;
    nodeVersions.forEach((nodeVersion:INodeVersion) => {
        // ensure this version supports your os and platform
        if (nodeVersion.files.indexOf(dataFileName) >= 0) {
            versions.push(nodeVersion.version);
        }
    });

    // get the latest version that matches the version spec
    let version: string = toolLib.evaluateVersions(versions, versionSpec);
    return version;
}
github actions / setup-node / src / installer.ts View on Github external
case 'linux':
      dataFileName = 'linux-' + osArch;
      break;
    case 'darwin':
      dataFileName = 'osx-' + osArch + '-tar';
      break;
    case 'win32':
      dataFileName = 'win-' + osArch + '-exe';
      break;
    default:
      throw new Error(`Unexpected OS '${osPlat}'`);
  }

  let versions: string[] = [];
  let dataUrl = 'https://nodejs.org/dist/index.json';
  let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
  let nodeVersions: INodeVersion[] =
    (await rest.get(dataUrl)).result || [];
  nodeVersions.forEach((nodeVersion: INodeVersion) => {
    // ensure this version supports your os and platform
    if (nodeVersion.files.indexOf(dataFileName) >= 0) {
      versions.push(nodeVersion.version);
    }
  });

  // get the latest version that matches the version spec
  let version: string = evaluateVersions(versions, versionSpec);
  return version;
}
github microsoft / typed-rest-client / test / units / resttests.ts View on Github external
before(() => {
        _rest = new restm.RestClient('typed-rest-client-tests');
        _restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
        _restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
        _queryParams = {
            params: {
                id: 1,
                foo: 'bar'
            }
        };
    });
github microsoft / typed-rest-client / test / units / resttests.ts View on Github external
before(() => {
        _rest = new restm.RestClient('typed-rest-client-tests');
        _restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
        _restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
        _queryParams = {
            params: {
                id: 1,
                foo: 'bar'
            }
        };
    });
github microsoft / typed-rest-client / test / resttests.ts View on Github external
before(() => {
        _rest = new restm.RestClient('typed-rest-client-tests');
        _restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
        _restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
    });
github GoogleCloudPlatform / github-actions / setup-gcloud / src / client-util.ts View on Github external
function getClient(): rest.RestClient {
  return new rest.RestClient('github-actions-setup-gcloud');
}
github jimhester / setup-r / src / installer.ts View on Github external
async function getAvailableVersions(): Promise {
  let rest: restm.RestClient = new restm.RestClient("setup-r");
  let tags: IRRef[] =
    (await rest.get("https://rversions.r-pkg.org/r-versions"))
      .result || [];

  return tags.map(tag => tag.version);
}
github r-lib / actions / setup-r / src / installer.ts View on Github external
async function getAvailableVersions(): Promise {
  let rest: restm.RestClient = new restm.RestClient("setup-r");
  let tags: IRRef[] =
    (await rest.get("https://rversions.r-pkg.org/r-versions"))
      .result || [];

  return tags.map(tag => tag.version);
}