How to use the @azure/ms-rest-js.Serializer function in @azure/ms-rest-js

To help you get started, we’ve selected a few @azure/ms-rest-js 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-js / packages / @azure / arm-subscriptions / lib / operations / subscriptionFactory.ts View on Github external
* @returns Promise
   */
  beginCreateSubscriptionInEnrollmentAccount(enrollmentAccountName: string, body: Models.SubscriptionCreationParameters, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        enrollmentAccountName,
        body,
        options
      },
      beginCreateSubscriptionInEnrollmentAccountOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginCreateSubscriptionInEnrollmentAccountOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription",
  urlParameters: [
    Parameters.enrollmentAccountName
  ],
  queryParameters: [
    Parameters.apiVersion0
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "body",
    mapper: {
      ...Mappers.SubscriptionCreationParameters,
github Azure / azure-sdk-for-js / sdk / network / arm-network / src / operations / vpnSitesConfiguration.ts View on Github external
*/
  beginDownload(resourceGroupName: string, virtualWANName: string, request: Models.GetVpnSitesConfigurationRequest, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        resourceGroupName,
        virtualWANName,
        request,
        options
      },
      beginDownloadOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginDownloadOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualWans/{virtualWANName}/vpnConfiguration",
  urlParameters: [
    Parameters.subscriptionId,
    Parameters.resourceGroupName,
    Parameters.virtualWANName0
  ],
  queryParameters: [
    Parameters.apiVersion0
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "request",
github Azure / azure-sdk-for-js / sdk / subscription / arm-subscriptions / src / operations / subscriptionFactory.ts View on Github external
* @returns Promise
   */
  beginCreateSubscriptionInEnrollmentAccount(enrollmentAccountName: string, body: Models.SubscriptionCreationParameters, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        enrollmentAccountName,
        body,
        options
      },
      beginCreateSubscriptionInEnrollmentAccountOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginCreateSubscriptionOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription",
  urlParameters: [
    Parameters.billingAccountName,
    Parameters.invoiceSectionName
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "body",
    mapper: {
github Azure / azure-sdk-for-js / sdk / compute / arm-compute / src / operations / logAnalytics.ts View on Github external
* @returns Promise
   */
  beginExportThrottledRequests(parameters: Models.ThrottledRequestsInput, location: string, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        parameters,
        location,
        options
      },
      beginExportThrottledRequestsOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginExportRequestRateByIntervalOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval",
  urlParameters: [
    Parameters.location1,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion0
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "parameters",
    mapper: {
github Azure / Azurite / src / utils / serializer.ts View on Github external
spec: msRest.OperationSpec,
  handlerResponse: any,
  logger: ILogger
): Promise {
  const statusCodeInResponse: number = handlerResponse.statusCode;
  res.setStatusCode(statusCodeInResponse);

  const responseSpec = spec.responses[statusCodeInResponse];
  if (!responseSpec) {
    throw new TypeError(
      `Request specification doesn't include provided response status code`
    );
  }

  // Serialize headers
  const headerSerializer = new msRest.Serializer(Mappers);
  const headersMapper = responseSpec.headersMapper;
  if (headersMapper && headersMapper.type.name === "Composite") {
    const mappersForAllHeaders = headersMapper.type.modelProperties || {};

    // Handle headerMapper one by one
    for (const key in mappersForAllHeaders) {
      if (mappersForAllHeaders.hasOwnProperty(key)) {
        const headerMapper = mappersForAllHeaders[key];
        const headerName = headerMapper.serializedName;
        const headerValueOriginal = handlerResponse[key];
        const headerValueSerialized = headerSerializer.serialize(
          headerMapper,
          headerValueOriginal
        );

        // Handle collection of headers starting with same prefix, such as x-ms-meta prefix
github Azure / azure-sdk-for-js / packages / @azure / arm-frontdoor / lib / operations / endpoints.ts View on Github external
*/
  beginPurgeContent(resourceGroupName: string, frontDoorName: string, contentFilePaths: Models.PurgeParameters, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        resourceGroupName,
        frontDoorName,
        contentFilePaths,
        options
      },
      beginPurgeContentOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginPurgeContentOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge",
  urlParameters: [
    Parameters.subscriptionId,
    Parameters.resourceGroupName0,
    Parameters.frontDoorName
  ],
  queryParameters: [
    Parameters.apiVersion
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "contentFilePaths",
github Azure / azure-sdk-for-js / packages / @azure / arm-sql / src / operations / managedInstanceTdeCertificates.ts View on Github external
*/
  beginCreate(resourceGroupName: string, managedInstanceName: string, parameters: Models.TdeCertificate, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        resourceGroupName,
        managedInstanceName,
        parameters,
        options
      },
      beginCreateOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginCreateOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/tdeCertificates",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.managedInstanceName,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "parameters",
github Azure / azure-sdk-for-js / packages / @azure / arm-sql / src / operations / tdeCertificates.ts View on Github external
*/
  beginCreate(resourceGroupName: string, serverName: string, parameters: Models.TdeCertificate, options?: msRest.RequestOptionsBase): Promise {
    return this.client.sendLRORequest(
      {
        resourceGroupName,
        serverName,
        parameters,
        options
      },
      beginCreateOperationSpec,
      options);
  }
}

// Operation Specifications
const serializer = new msRest.Serializer(Mappers);
const beginCreateOperationSpec: msRest.OperationSpec = {
  httpMethod: "POST",
  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/tdeCertificates",
  urlParameters: [
    Parameters.resourceGroupName,
    Parameters.serverName,
    Parameters.subscriptionId
  ],
  queryParameters: [
    Parameters.apiVersion2
  ],
  headerParameters: [
    Parameters.acceptLanguage
  ],
  requestBody: {
    parameterPath: "parameters",
github Azure / Azurite / src / PreflightMiddlewareFactory.ts View on Github external
const context = new BlobStorageContext(res.locals, DEFAULT_CONTEXT_PATH);
    const handlerResponse = context.handlerResponses;

    if (handlerResponse && context.operation) {
      const statusCodeInResponse: number = handlerResponse.statusCode;
      const spec = Specifications[context.operation];
      const responseSpec = spec.responses[statusCodeInResponse];
      if (!responseSpec) {
        throw new TypeError(
          `Request specification doesn't include provided response status code`
        );
      }

      // Serialize headers
      const headerSerializer = new msRest.Serializer(Mappers);
      const headersMapper = responseSpec.headersMapper;

      if (headersMapper && headersMapper.type.name === "Composite") {
        const mappersForAllHeaders = headersMapper.type.modelProperties || {};

        // Handle headerMapper one by one
        for (const key in mappersForAllHeaders) {
          if (mappersForAllHeaders.hasOwnProperty(key)) {
            const headerMapper = mappersForAllHeaders[key];
            const headerName = headerMapper.serializedName;
            const headerValueOriginal = handlerResponse[key];
            const headerValueSerialized = headerSerializer.serialize(
              headerMapper,
              headerValueOriginal
            );
github Azure / azure-sdk-for-js / test / azureServiceClientTests.ts View on Github external
serializedName: "date",
                    required: true,
                    type: {
                      name: "DateTime"
                    }
                  }
                }
              }
            }
          },
          201: {},
          default: {
            bodyMapper: CloudErrorMapper
          }
        },
        serializer: new Serializer()
      };

      const lroPoller: LROPoller = await serviceClient.sendLRORequest(operationArguments, operationSpec, options);
      assert.strictEqual(lroPoller.isFinished(), false);
      assert.strictEqual(lroPoller.isFinalStatusAcceptable(), undefined);
      assert.strictEqual(lroPoller.getOperationStatus(), "InProgress");
      assert.strictEqual(await lroPoller.getOperationResponse(), undefined);
      assert.strictEqual(lroPoller.getMostRecentResponse().request.url, "https://fake.azure.com/longRunningOperation");
      assert.strictEqual(lroPoller.getMostRecentResponse().request.headers.get("x-ms-client-request-id"), requestId);

      assert.strictEqual(await lroPoller.poll(), "Succeeded");

      assert.strictEqual(lroPoller.isFinished(), true);
      assert.strictEqual(lroPoller.isFinalStatusAcceptable(), true);
      assert.strictEqual(lroPoller.getOperationStatus(), "Succeeded");
      assert.strictEqual(lroPoller.getMostRecentResponse().request.url, "https://fake.azure.com/longRunningOperation2");