text: "use strict";
  /*
   * Code generated by Microsoft (R) AutoRest Code Generator.
   * Changes may cause incorrect behavior and will be lost if the code is
   * regenerated.
   */
  var __assign = (this && this.__assign) || Object.assign || function(t) {
      for (var s, i = 1, n = arguments.length; i < n; i++) {
          s = arguments[i];
          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
              t[p] = s[p];
      }
      return t;
  };
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
      return new (P || (P = Promise))(function (resolve, reject) {
          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
          step((generator = generator.apply(thisArg, _arguments || [])).next());
      });
  };
  var __generator = (this && this.__generator) || function (thisArg, body) {
      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
      function verb(n) { return function (v) { return step([n, v]); }; }
      function step(op) {
          if (f) throw new TypeError("Generator is already executing.");
          while (_) try {
              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
              if (y = 0, t) op = [op[0] & 2, t.value];
              switch (op[0]) {
                  case 0: case 1: t = op; break;
                  case 4: _.label++; return { value: op[1], done: false };
                  case 5: _.label++; y = op[1]; op = [0]; continue;
                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
                  default:
                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                      if (t[2]) _.ops.pop();
                      _.trys.pop(); continue;
              }
              op = body.call(thisArg, _);
          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
      }
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  var msRest = require("ms-rest-js");
  var Mappers = require("../models/subnetsMappers");
  var WebResource = msRest.WebResource;
  /** Class representing a Subnets. */
  var Subnets = /** @class */ (function () {
      /**
       * Create a Subnets.
       * @param {NetworkManagementClientContext} client Reference to the service client.
       */
      function Subnets(client) {
          this.serializer = new msRest.Serializer(Mappers);
          this.client = client;
      }
      /**
       * Deletes the specified subnet.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {string} subnetName The name of the subnet.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.deleteMethodWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, subnetName, options) {
          return __awaiter(this, void 0, void 0, function () {
              var client, initialResult, err_1, operationRes, err_2;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          client = this.client;
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          return [4 /*yield*/, this.beginDeleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options)];
                      case 2:
                          initialResult = _a.sent();
                          return [3 /*break*/, 4];
                      case 3:
                          err_1 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_1)];
                      case 4:
                          _a.trys.push([4, 6, , 7]);
                          return [4 /*yield*/, client.getLongRunningOperationResult(initialResult, options)];
                      case 5:
                          operationRes = _a.sent();
                          return [3 /*break*/, 7];
                      case 6:
                          err_2 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_2)];
                      case 7: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Gets the specified subnet by virtual network and resource group.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {string} subnetName The name of the subnet.
       *
       * @param {SubnetsGetOptionalParams} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.getWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, subnetName, options) {
          return __awaiter(this, void 0, void 0, function () {
              var expand, apiVersion, httpRequest, operationRes, operationArguments, statusCode, parsedResponse, resultMapper, deserializationError, err_3;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          expand = (options && options.expand !== undefined) ? options.expand : undefined;
                          apiVersion = '2017-10-01';
                          httpRequest = new WebResource();
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          operationArguments = msRest.createOperationArguments({
                              resourceGroupName: resourceGroupName,
                              virtualNetworkName: virtualNetworkName,
                              subnetName: subnetName,
                              apiVersion: apiVersion,
                              "this.client.subscriptionId": this.client.subscriptionId,
                              expand: expand,
                              "this.client.acceptLanguage": this.client.acceptLanguage
                          }, options);
                          return [4 /*yield*/, this.client.sendOperationRequest(httpRequest, operationArguments, {
                                  httpMethod: "GET",
                                  baseUrl: this.client.baseUri,
                                  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}",
                                  urlParameters: [
                                      {
                                          parameterPath: "resourceGroupName",
                                          mapper: {
                                              required: true,
                                              serializedName: "resourceGroupName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "virtualNetworkName",
                                          mapper: {
                                              required: true,
                                              serializedName: "virtualNetworkName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "subnetName",
                                          mapper: {
                                              required: true,
                                              serializedName: "subnetName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "this.client.subscriptionId",
                                          mapper: {
                                              required: true,
                                              serializedName: "subscriptionId",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  queryParameters: [
                                      {
                                          parameterPath: "apiVersion",
                                          mapper: {
                                              required: true,
                                              isConstant: true,
                                              serializedName: "api-version",
                                              defaultValue: '2017-10-01',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "expand",
                                          mapper: {
                                              serializedName: "$expand",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  headerParameters: [
                                      {
                                          parameterPath: "this.client.acceptLanguage",
                                          mapper: {
                                              serializedName: "accept-language",
                                              defaultValue: 'en-US',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  responses: {
                                      200: {
                                          bodyMapper: Mappers.Subnet
                                      },
                                      default: {
                                          bodyMapper: Mappers.CloudError
                                      }
                                  },
                                  serializer: this.serializer
                              })];
                      case 2:
                          operationRes = _a.sent();
                          statusCode = operationRes.status;
                          if (statusCode === 200) {
                              parsedResponse = operationRes.parsedBody;
                              try {
                                  if (parsedResponse != undefined) {
                                      resultMapper = Mappers.Subnet;
                                      operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                                  }
                              }
                              catch (error) {
                                  deserializationError = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                                  deserializationError.request = msRest.stripRequest(httpRequest);
                                  deserializationError.response = msRest.stripResponse(operationRes);
                                  return [2 /*return*/, Promise.reject(deserializationError)];
                              }
                          }
                          return [3 /*break*/, 4];
                      case 3:
                          err_3 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_3)];
                      case 4: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Creates or updates a subnet in the specified virtual network.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {string} subnetName The name of the subnet.
       *
       * @param {Subnet} subnetParameters Parameters supplied to the create or update subnet operation.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.createOrUpdateWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options) {
          return __awaiter(this, void 0, void 0, function () {
              var client, initialResult, err_4, operationRes, httpRequest, parsedResponse, resultMapper, deserializationError, err_5;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          client = this.client;
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          return [4 /*yield*/, this.beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options)];
                      case 2:
                          initialResult = _a.sent();
                          return [3 /*break*/, 4];
                      case 3:
                          err_4 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_4)];
                      case 4:
                          _a.trys.push([4, 6, , 7]);
                          return [4 /*yield*/, client.getLongRunningOperationResult(initialResult, options)];
                      case 5:
                          operationRes = _a.sent();
                          httpRequest = operationRes.request;
                          parsedResponse = operationRes.parsedBody;
                          try {
                              if (parsedResponse != undefined) {
                                  resultMapper = Mappers.Subnet;
                                  operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                              }
                          }
                          catch (error) {
                              deserializationError = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                              deserializationError.request = msRest.stripRequest(httpRequest);
                              deserializationError.response = msRest.stripResponse(operationRes);
                              return [2 /*return*/, Promise.reject(deserializationError)];
                          }
                          return [3 /*break*/, 7];
                      case 6:
                          err_5 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_5)];
                      case 7: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Gets all subnets in a virtual network.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.listWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, options) {
          return __awaiter(this, void 0, void 0, function () {
              var apiVersion, httpRequest, operationRes, operationArguments, statusCode, parsedResponse, resultMapper, deserializationError, err_6;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          apiVersion = '2017-10-01';
                          httpRequest = new WebResource();
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          operationArguments = msRest.createOperationArguments({
                              resourceGroupName: resourceGroupName,
                              virtualNetworkName: virtualNetworkName,
                              apiVersion: apiVersion,
                              "this.client.subscriptionId": this.client.subscriptionId,
                              "this.client.acceptLanguage": this.client.acceptLanguage
                          }, options);
                          return [4 /*yield*/, this.client.sendOperationRequest(httpRequest, operationArguments, {
                                  httpMethod: "GET",
                                  baseUrl: this.client.baseUri,
                                  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets",
                                  urlParameters: [
                                      {
                                          parameterPath: "resourceGroupName",
                                          mapper: {
                                              required: true,
                                              serializedName: "resourceGroupName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "virtualNetworkName",
                                          mapper: {
                                              required: true,
                                              serializedName: "virtualNetworkName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "this.client.subscriptionId",
                                          mapper: {
                                              required: true,
                                              serializedName: "subscriptionId",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  queryParameters: [
                                      {
                                          parameterPath: "apiVersion",
                                          mapper: {
                                              required: true,
                                              isConstant: true,
                                              serializedName: "api-version",
                                              defaultValue: '2017-10-01',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  headerParameters: [
                                      {
                                          parameterPath: "this.client.acceptLanguage",
                                          mapper: {
                                              serializedName: "accept-language",
                                              defaultValue: 'en-US',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  responses: {
                                      200: {
                                          bodyMapper: Mappers.SubnetListResult
                                      },
                                      default: {
                                          bodyMapper: Mappers.CloudError
                                      }
                                  },
                                  serializer: this.serializer
                              })];
                      case 2:
                          operationRes = _a.sent();
                          statusCode = operationRes.status;
                          if (statusCode === 200) {
                              parsedResponse = operationRes.parsedBody;
                              try {
                                  if (parsedResponse != undefined) {
                                      resultMapper = Mappers.SubnetListResult;
                                      operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                                  }
                              }
                              catch (error) {
                                  deserializationError = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                                  deserializationError.request = msRest.stripRequest(httpRequest);
                                  deserializationError.response = msRest.stripResponse(operationRes);
                                  return [2 /*return*/, Promise.reject(deserializationError)];
                              }
                          }
                          return [3 /*break*/, 4];
                      case 3:
                          err_6 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_6)];
                      case 4: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Deletes the specified subnet.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {string} subnetName The name of the subnet.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.beginDeleteMethodWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, subnetName, options) {
          return __awaiter(this, void 0, void 0, function () {
              var apiVersion, httpRequest, operationRes, operationArguments, err_7;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          apiVersion = '2017-10-01';
                          httpRequest = new WebResource();
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          operationArguments = msRest.createOperationArguments({
                              resourceGroupName: resourceGroupName,
                              virtualNetworkName: virtualNetworkName,
                              subnetName: subnetName,
                              apiVersion: apiVersion,
                              "this.client.subscriptionId": this.client.subscriptionId,
                              "this.client.acceptLanguage": this.client.acceptLanguage
                          }, options);
                          return [4 /*yield*/, this.client.sendOperationRequest(httpRequest, operationArguments, {
                                  httpMethod: "DELETE",
                                  baseUrl: this.client.baseUri,
                                  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}",
                                  urlParameters: [
                                      {
                                          parameterPath: "resourceGroupName",
                                          mapper: {
                                              required: true,
                                              serializedName: "resourceGroupName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "virtualNetworkName",
                                          mapper: {
                                              required: true,
                                              serializedName: "virtualNetworkName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "subnetName",
                                          mapper: {
                                              required: true,
                                              serializedName: "subnetName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "this.client.subscriptionId",
                                          mapper: {
                                              required: true,
                                              serializedName: "subscriptionId",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  queryParameters: [
                                      {
                                          parameterPath: "apiVersion",
                                          mapper: {
                                              required: true,
                                              isConstant: true,
                                              serializedName: "api-version",
                                              defaultValue: '2017-10-01',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  headerParameters: [
                                      {
                                          parameterPath: "this.client.acceptLanguage",
                                          mapper: {
                                              serializedName: "accept-language",
                                              defaultValue: 'en-US',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  responses: {
                                      200: {},
                                      204: {},
                                      202: {},
                                      default: {
                                          bodyMapper: Mappers.CloudError
                                      }
                                  },
                                  serializer: this.serializer
                              })];
                      case 2:
                          operationRes = _a.sent();
                          return [3 /*break*/, 4];
                      case 3:
                          err_7 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_7)];
                      case 4: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Creates or updates a subnet in the specified virtual network.
       *
       * @param {string} resourceGroupName The name of the resource group.
       *
       * @param {string} virtualNetworkName The name of the virtual network.
       *
       * @param {string} subnetName The name of the subnet.
       *
       * @param {Subnet} subnetParameters Parameters supplied to the create or update subnet operation.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.beginCreateOrUpdateWithHttpOperationResponse = function (resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options) {
          return __awaiter(this, void 0, void 0, function () {
              var apiVersion, httpRequest, operationRes, operationArguments, statusCode, parsedResponse, resultMapper, deserializationError, parsedResponse, resultMapper, deserializationError1, err_8;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          apiVersion = '2017-10-01';
                          httpRequest = new WebResource();
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          operationArguments = msRest.createOperationArguments({
                              resourceGroupName: resourceGroupName,
                              virtualNetworkName: virtualNetworkName,
                              subnetName: subnetName,
                              subnetParameters: subnetParameters,
                              apiVersion: apiVersion,
                              "this.client.subscriptionId": this.client.subscriptionId,
                              "this.client.acceptLanguage": this.client.acceptLanguage
                          }, options);
                          return [4 /*yield*/, this.client.sendOperationRequest(httpRequest, operationArguments, {
                                  httpMethod: "PUT",
                                  baseUrl: this.client.baseUri,
                                  path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}",
                                  urlParameters: [
                                      {
                                          parameterPath: "resourceGroupName",
                                          mapper: {
                                              required: true,
                                              serializedName: "resourceGroupName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "virtualNetworkName",
                                          mapper: {
                                              required: true,
                                              serializedName: "virtualNetworkName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "subnetName",
                                          mapper: {
                                              required: true,
                                              serializedName: "subnetName",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      },
                                      {
                                          parameterPath: "this.client.subscriptionId",
                                          mapper: {
                                              required: true,
                                              serializedName: "subscriptionId",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  queryParameters: [
                                      {
                                          parameterPath: "apiVersion",
                                          mapper: {
                                              required: true,
                                              isConstant: true,
                                              serializedName: "api-version",
                                              defaultValue: '2017-10-01',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  headerParameters: [
                                      {
                                          parameterPath: "this.client.acceptLanguage",
                                          mapper: {
                                              serializedName: "accept-language",
                                              defaultValue: 'en-US',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  requestBody: {
                                      parameterPath: "subnetParameters",
                                      mapper: __assign({}, Mappers.Subnet, { required: true })
                                  },
                                  contentType: "application/json; charset=utf-8",
                                  responses: {
                                      200: {
                                          bodyMapper: Mappers.Subnet
                                      },
                                      201: {
                                          bodyMapper: Mappers.Subnet
                                      },
                                      default: {
                                          bodyMapper: Mappers.CloudError
                                      }
                                  },
                                  serializer: this.serializer
                              })];
                      case 2:
                          operationRes = _a.sent();
                          statusCode = operationRes.status;
                          if (statusCode === 200) {
                              parsedResponse = operationRes.parsedBody;
                              try {
                                  if (parsedResponse != undefined) {
                                      resultMapper = Mappers.Subnet;
                                      operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                                  }
                              }
                              catch (error) {
                                  deserializationError = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                                  deserializationError.request = msRest.stripRequest(httpRequest);
                                  deserializationError.response = msRest.stripResponse(operationRes);
                                  return [2 /*return*/, Promise.reject(deserializationError)];
                              }
                          }
                          if (statusCode === 201) {
                              parsedResponse = operationRes.parsedBody;
                              try {
                                  if (parsedResponse != undefined) {
                                      resultMapper = Mappers.Subnet;
                                      operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                                  }
                              }
                              catch (error) {
                                  deserializationError1 = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                                  deserializationError1.request = msRest.stripRequest(httpRequest);
                                  deserializationError1.response = msRest.stripResponse(operationRes);
                                  return [2 /*return*/, Promise.reject(deserializationError1)];
                              }
                          }
                          return [3 /*break*/, 4];
                      case 3:
                          err_8 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_8)];
                      case 4: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      /**
       * Gets all subnets in a virtual network.
       *
       * @param {string} nextPageLink The NextLink from the previous successful call to List operation.
       *
       * @param {RequestOptionsBase} [options] Optional Parameters.
       *
       * @returns {Promise} A promise is returned
       *
       * @resolve {HttpOperationResponse} The deserialized result object.
       *
       * @reject {Error|ServiceError} The error object.
       */
      Subnets.prototype.listNextWithHttpOperationResponse = function (nextPageLink, options) {
          return __awaiter(this, void 0, void 0, function () {
              var httpRequest, operationRes, operationArguments, statusCode, parsedResponse, resultMapper, deserializationError, err_9;
              return __generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          httpRequest = new WebResource();
                          _a.label = 1;
                      case 1:
                          _a.trys.push([1, 3, , 4]);
                          operationArguments = msRest.createOperationArguments({
                              nextPageLink: nextPageLink,
                              "this.client.acceptLanguage": this.client.acceptLanguage
                          }, options);
                          return [4 /*yield*/, this.client.sendOperationRequest(httpRequest, operationArguments, {
                                  httpMethod: "GET",
                                  baseUrl: "https://management.azure.com",
                                  path: "{nextLink}",
                                  urlParameters: [
                                      {
                                          parameterPath: "nextPageLink",
                                          skipEncoding: true,
                                          mapper: {
                                              required: true,
                                              serializedName: "nextLink",
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  headerParameters: [
                                      {
                                          parameterPath: "this.client.acceptLanguage",
                                          mapper: {
                                              serializedName: "accept-language",
                                              defaultValue: 'en-US',
                                              type: {
                                                  name: "String"
                                              }
                                          }
                                      }
                                  ],
                                  responses: {
                                      200: {
                                          bodyMapper: Mappers.SubnetListResult
                                      },
                                      default: {
                                          bodyMapper: Mappers.CloudError
                                      }
                                  },
                                  serializer: this.serializer
                              })];
                      case 2:
                          operationRes = _a.sent();
                          statusCode = operationRes.status;
                          if (statusCode === 200) {
                              parsedResponse = operationRes.parsedBody;
                              try {
                                  if (parsedResponse != undefined) {
                                      resultMapper = Mappers.SubnetListResult;
                                      operationRes.parsedBody = this.serializer.deserialize(resultMapper, parsedResponse, 'operationRes.parsedBody');
                                  }
                              }
                              catch (error) {
                                  deserializationError = new msRest.RestError("Error " + error + " occurred in deserializing the responseBody - " + operationRes.bodyAsText);
                                  deserializationError.request = msRest.stripRequest(httpRequest);
                                  deserializationError.response = msRest.stripResponse(operationRes);
                                  return [2 /*return*/, Promise.reject(deserializationError)];
                              }
                          }
                          return [3 /*break*/, 4];
                      case 3:
                          err_9 = _a.sent();
                          return [2 /*return*/, Promise.reject(err_9)];
                      case 4: return [2 /*return*/, Promise.resolve(operationRes)];
                  }
              });
          });
      };
      Subnets.prototype.deleteMethod = function (resourceGroupName, virtualNetworkName, subnetName, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.deleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.deleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.get = function (resourceGroupName, virtualNetworkName, subnetName, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.getWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.getWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.createOrUpdate = function (resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.createOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.createOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.list = function (resourceGroupName, virtualNetworkName, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.listWithHttpOperationResponse(resourceGroupName, virtualNetworkName, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.listWithHttpOperationResponse(resourceGroupName, virtualNetworkName, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.beginDeleteMethod = function (resourceGroupName, virtualNetworkName, subnetName, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.beginDeleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.beginDeleteMethodWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.beginCreateOrUpdate = function (resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      Subnets.prototype.listNext = function (nextPageLink, options, callback) {
          if (!callback && typeof options === 'function') {
              callback = options;
              options = undefined;
          }
          var cb = callback;
          if (!callback) {
              return this.listNextWithHttpOperationResponse(nextPageLink, options).then(function (operationRes) {
                  return Promise.resolve(operationRes.parsedBody);
              }).catch(function (err) {
                  return Promise.reject(err);
              });
          }
          else {
              msRest.promiseToCallback(this.listNextWithHttpOperationResponse(nextPageLink, options))(function (err, data) {
                  if (err) {
                      return cb(err);
                  }
                  var result = data.parsedBody;
                  return cb(err, result, data.request, data);
              });
          }
      };
      return Subnets;
  }());
  exports.Subnets = Subnets;
  //# sourceMappingURL=subnets.js.map