How to use the ms-rest.isValidUuid function in ms-rest

To help you get started, we’ve selected a few ms-rest 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 Azure / azure-sdk-for-node / lib / services / automationManagement / lib / operations / jobScheduleOperations.js View on Github external
{
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
      throw new Error('automationAccountName cannot be null or undefined and it must be of type string.');
    }
    if (jobScheduleId === null || jobScheduleId === undefined || typeof jobScheduleId.valueOf() !== 'string' || !msRest.isValidUuid(jobScheduleId)) {
      throw new Error('jobScheduleId cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
github Azure / azure-sdk-for-node / lib / services / customVision / prediction / lib / predictionAPIClient.js View on Github external
let client = this;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined;
  let application = (options && options.application !== undefined) ? options.application : undefined;
  // Validate
  try {
    if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') {
      throw new Error('this.endpoint cannot be null or undefined and it must be of type string.');
    }
    if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) {
      throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) {
      throw new Error('iterationId must be of type string and must be a valid uuid.');
    }
    if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') {
      throw new Error('application must be of type string.');
    }
    if (imageData === null || imageData === undefined) {
      throw new Error('imageData cannot be null or undefined and it must be of type object.');
    }
    if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') {
      throw new Error('this.apiKey cannot be null or undefined and it must be of type string.');
    }
  } catch (error) {
    return callback(error);
github Azure / azure-sdk-for-node / lib / services / search / lib / service / operations / indexes.js View on Github external
}
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }
  let clientRequestId;
  try {
    if (searchRequestOptions !== null && searchRequestOptions !== undefined)
    {
      clientRequestId = searchRequestOptions.clientRequestId;
      if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
        throw new Error('clientRequestId must be of type string and must be a valid uuid.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'indexes(\'{indexName}\')';
  requestUrl = requestUrl.replace('{indexName}', encodeURIComponent(indexName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }
github Azure / azure-sdk-for-node / lib / services / customVision / prediction / lib / predictionAPIClient.js View on Github external
throw new Error('callback cannot be null.');
  }
  let iterationId = (options && options.iterationId !== undefined) ? options.iterationId : undefined;
  let application = (options && options.application !== undefined) ? options.application : undefined;
  // Validate
  try {
    if (this.endpoint === null || this.endpoint === undefined || typeof this.endpoint.valueOf() !== 'string') {
      throw new Error('this.endpoint cannot be null or undefined and it must be of type string.');
    }
    if (projectId === null || projectId === undefined || typeof projectId.valueOf() !== 'string' || !msRest.isValidUuid(projectId)) {
      throw new Error('projectId cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (imageUrl === null || imageUrl === undefined) {
      throw new Error('imageUrl cannot be null or undefined.');
    }
    if (iterationId !== null && iterationId !== undefined && !(typeof iterationId.valueOf() === 'string' && msRest.isValidUuid(iterationId))) {
      throw new Error('iterationId must be of type string and must be a valid uuid.');
    }
    if (application !== null && application !== undefined && typeof application.valueOf() !== 'string') {
      throw new Error('application must be of type string.');
    }
    if (this.apiKey === null || this.apiKey === undefined || typeof this.apiKey.valueOf() !== 'string') {
      throw new Error('this.apiKey cannot be null or undefined and it must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{projectId}/url/nostore';
  requestUrl = requestUrl.replace('{Endpoint}', this.endpoint);
github Azure / azure-sdk-for-node / lib / services / search / lib / service / operations / indexes.js View on Github external
}
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }
  let clientRequestId;
  try {
    if (searchRequestOptions !== null && searchRequestOptions !== undefined)
    {
      clientRequestId = searchRequestOptions.clientRequestId;
      if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
        throw new Error('clientRequestId must be of type string and must be a valid uuid.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'indexes';
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }
github microsoft / appcenter-cli / src / util / apis / generated / operations / dataSubjectRight.js View on Github external
function _exportStatusRequest(token, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (token === null || token === undefined || typeof token.valueOf() !== 'string' || !msRest.isValidUuid(token)) {
      throw new Error('token cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/user/dsr/export/{token}';
  requestUrl = requestUrl.replace('{token}', encodeURIComponent(token.toString()));

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'GET';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
github Azure / azure-sdk-for-node / lib / services / dataLake.Analytics / lib / job / operations / pipelineModel.js View on Github external
options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let startDateTime = (options && options.startDateTime !== undefined) ? options.startDateTime : undefined;
  let endDateTime = (options && options.endDateTime !== undefined) ? options.endDateTime : undefined;
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (pipelineIdentity === null || pipelineIdentity === undefined || typeof pipelineIdentity.valueOf() !== 'string' || !msRest.isValidUuid(pipelineIdentity)) {
      throw new Error('pipelineIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (startDateTime && !(startDateTime instanceof Date ||
        (typeof startDateTime.valueOf() === 'string' && !isNaN(Date.parse(startDateTime))))) {
          throw new Error('startDateTime must be of type date.');
        }
    if (endDateTime && !(endDateTime instanceof Date ||
        (typeof endDateTime.valueOf() === 'string' && !isNaN(Date.parse(endDateTime))))) {
          throw new Error('endDateTime must be of type date.');
        }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
github Azure / azure-sdk-for-node / lib / services / cognitiveServicesFace / lib / operations / personGroupPerson.js View on Github external
throw new Error('personGroupId cannot be null or undefined and it must be of type string.');
    }
    if (personGroupId !== null && personGroupId !== undefined) {
      if (personGroupId.length > 64)
      {
        throw new Error('"personGroupId" should satisfy the constraint - "MaxLength": 64');
      }
      if (personGroupId.match(/^[a-z0-9-_]+$/) === null)
      {
        throw new Error('"personGroupId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/');
      }
    }
    if (personId === null || personId === undefined || typeof personId.valueOf() !== 'string' || !msRest.isValidUuid(personId)) {
      throw new Error('personId cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (persistedFaceId === null || persistedFaceId === undefined || typeof persistedFaceId.valueOf() !== 'string' || !msRest.isValidUuid(persistedFaceId)) {
      throw new Error('persistedFaceId cannot be null or undefined and it must be of type string and must be a valid uuid.');
    }
    if (userData !== null && userData !== undefined && typeof userData.valueOf() !== 'string') {
      throw new Error('userData must be of type string.');
    }
    if (userData !== null && userData !== undefined) {
      if (userData.length > 1024)
      {
        throw new Error('"userData" should satisfy the constraint - "MaxLength": 1024');
      }
    }
  } catch (error) {
    return callback(error);
  }
  let body;
  if (userData !== null && userData !== undefined) {
github Azure / azure-sdk-for-node / lib / services / cognitiveServicesFace / lib / operations / face.js View on Github external
if (largeFaceListId !== null && largeFaceListId !== undefined && typeof largeFaceListId.valueOf() !== 'string') {
      throw new Error('largeFaceListId must be of type string.');
    }
    if (largeFaceListId !== null && largeFaceListId !== undefined) {
      if (largeFaceListId.length > 64)
      {
        throw new Error('"largeFaceListId" should satisfy the constraint - "MaxLength": 64');
      }
      if (largeFaceListId.match(/^[a-z0-9-_]+$/) === null)
      {
        throw new Error('"largeFaceListId" should satisfy the constraint - "Pattern": /^[a-z0-9-_]+$/');
      }
    }
    if (Array.isArray(faceIds)) {
      for (let i = 0; i < faceIds.length; i++) {
        if (faceIds[i] !== null && faceIds[i] !== undefined && !(typeof faceIds[i].valueOf() === 'string' && msRest.isValidUuid(faceIds[i]))) {
          throw new Error('faceIds[i] must be of type string and must be a valid uuid.');
        }
      }
    }
    if (faceIds !== null && faceIds !== undefined) {
      if (faceIds.length > 1000)
      {
        throw new Error('"faceIds" should satisfy the constraint - "MaxItems": 1000');
      }
    }
    if (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined && typeof maxNumOfCandidatesReturned !== 'number') {
      throw new Error('maxNumOfCandidatesReturned must be of type number.');
    }
    if (maxNumOfCandidatesReturned !== null && maxNumOfCandidatesReturned !== undefined) {
      if (maxNumOfCandidatesReturned > 1000)
      {
github Azure / azure-sdk-for-node / lib / services / batch / lib / operations / file.js View on Github external
var returnClientRequestId;
  var ocpDate;
  var ifModifiedSince;
  var ifUnmodifiedSince;
  try {
    if (fileGetPropertiesFromTaskOptions !== null && fileGetPropertiesFromTaskOptions !== undefined)
    {
      timeout = fileGetPropertiesFromTaskOptions.timeout;
      if (timeout !== null && timeout !== undefined && typeof timeout !== 'number') {
        throw new Error('timeout must be of type number.');
      }
    }
    if (fileGetPropertiesFromTaskOptions !== null && fileGetPropertiesFromTaskOptions !== undefined)
    {
      clientRequestId = fileGetPropertiesFromTaskOptions.clientRequestId;
      if (clientRequestId !== null && clientRequestId !== undefined && !(typeof clientRequestId.valueOf() === 'string' && msRest.isValidUuid(clientRequestId))) {
        throw new Error('clientRequestId must be of type string and must be a valid uuid.');
      }
    }
    if (fileGetPropertiesFromTaskOptions !== null && fileGetPropertiesFromTaskOptions !== undefined)
    {
      returnClientRequestId = fileGetPropertiesFromTaskOptions.returnClientRequestId;
      if (returnClientRequestId !== null && returnClientRequestId !== undefined && typeof returnClientRequestId !== 'boolean') {
        throw new Error('returnClientRequestId must be of type boolean.');
      }
    }
    if (fileGetPropertiesFromTaskOptions !== null && fileGetPropertiesFromTaskOptions !== undefined)
    {
      ocpDate = fileGetPropertiesFromTaskOptions.ocpDate;
      if (ocpDate && !(ocpDate instanceof Date ||
          (typeof ocpDate.valueOf() === 'string' && !isNaN(Date.parse(ocpDate))))) {
            throw new Error('ocpDate must be of type date.');